maven把java项目打包,如何把配置文件提出来

 我来答
198901245631
推荐于2016-03-13 · TA获得超过3.5万个赞
知道大有可为答主
回答量:9037
采纳率:92%
帮助的人:1694万
展开全部

你好:这个把配置文件提取出来可以再pm.xml里面配置java项目文件路径下文件打包方式来实现。举例如下,参考下。

<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.tmtpt</groupId>
<artifactId>tmrpt</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>

<artifactId>tmrpt-client</artifactId>
<version>2.2.2</version>
<name>vpetl-client</name>
<url>www.tmrpt.com</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.sun.jna</groupId>
<artifactId>jna</artifactId>
<version>4.0.0</version>
</dependency>
</dependencies>
<build>
<finalName>tmrpt-client</finalName>
<defaultGoal>install</defaultGoal>
<plugins>
<!-- <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> 
<version>2.3.2</version> <configuration> <source>1.6</source> <target>1.6</target> 
<encoding>UTF-8</encoding> </configuration> </plugin> -->

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.vprisk.main.EtlClientStart</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classesDirectory>${basedir}/target/classes</classesDirectory>
<finalName>${project.artifactId}-${project.version}</finalName>
<outputDirectory>${basedir}/target/maven-archiver</outputDirectory>
<excludes>
<exclude>*.conf</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
<!-- 拷贝依赖的jar包到lib目录 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>
${project.build.directory}/maven-archiver/lib
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>  
                <artifactId>maven-resources-plugin</artifactId>  
                <executions>  
                    <execution>  
                        <id>copy-resources</id>  
                        <phase>package</phase>  
                        <goals>  
                            <goal>copy-resources</goal>  
                        </goals>  
                        <configuration>  
                            <outputDirectory>${project.build.directory}/maven-archiver/resources</outputDirectory>  
                            <resources>  
                                <resource>  
                                    <directory>${basedir}/resources</directory>  
                                    <filtering>true</filtering>  
                                </resource>  
                            </resources>  
                        </configuration>  
                    </execution>  
                </executions>  
            </plugin>  
<!-- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<encoding>UTF-8</encoding>
<appendAssemblyId>true</appendAssemblyId>
<descriptors>
<descriptor>${basedir}/src/assembly.xml</descriptor>
</descriptors>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix />
<mainClass>com.vprisk.main.EtlserverStart</mainClass>
</manifest>

<manifestEntries>
<Class-Path>.</Class-Path>
</manifestEntries>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id> this is used for inheritance merges
<phase>package</phase> bind to the packaging phase
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin> -->
</plugins>
</build>
</project>
佳达源
2024-10-28 广告
AR0144CSSM20SUKA0-CPBR这款产品,作为我司产品线中的重要一员,集成了高精度的传感器技术与先进的图像处理算法,广泛应用于安防监控、工业自动化及机器视觉等领域。其卓越的性能与稳定性,确保了在各种复杂环境下的精准数据采集与高效... 点击进入详情页
本回答由佳达源提供
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式