Maven 打包时丢失properties文件
来源:互联网 发布:淘宝浏览app赚佣金 编辑:程序博客网 时间:2024/05/21 08:57
今天在打包项目war文件的时候,突然发现居然每个action包里面的properties文件都没打进来,在网上看了半天终于找到解决方法。
问题:maven执行package命令打包时,src/main/java路径下的properties文件偶尔丢失
解决方式:pom.xml中加入resources配置
<build><finalName>sx-user-cernter-provider</finalName><!--install 后包的名字--><sourceDirectory>src/main/java</sourceDirectory><!-- class文件 的目录 --><resources><resource><!-- instrall 时会过滤掉 不需要打包的文件--><targetPath>${project.build.directory}/classes/META-INF/spring</targetPath><directory>src/main/resources/META-INF/spring</directory><filtering>true</filtering><excludes><exclude>*.xml</exclude><exclude>*.properties</exclude></excludes></resource><resource><!--配置需要所有的java文件--><directory>src/main/java</directory><excludes><exclude>**/*.java</exclude></excludes></resource></resources><plugins><!-- 打包jar文件时,配置manifest文件,加入lib包的jar依赖 --><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-jar-plugin</artifactId><configuration><classesDirectory>target/classes/</classesDirectory><excludes><exclude>**/provider.properties</exclude><exclude>*.properties</exclude><exclude>**/datasource/**</exclude><exclude>*.xml</exclude></excludes><archive><addMavenDescriptor>false</addMavenDescriptor></archive></configuration></plugin><!-- 拷贝依赖的jar包到lib目录 --><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-dependency-plugin</artifactId><executions><execution><id>copy</id><phase>package</phase><goals><goal>copy-dependencies</goal></goals><configuration><outputDirectory>${project.build.directory}/lib</outputDirectory></configuration></execution></executions></plugin> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <descriptor>src/main/assembly/assembly.xml</descriptor> </configuration> <executions> <execution> <id>make-assembly</id> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin></plugins></build>
说明:
首先了解maven生命周期如下:
生命周期阶段目标process-resourcesresources:resourcescompilecompiler:compileprocess-test-resourcesresources:testResourcestest-compilecompiler:testCompiletestsurefire:testpackagewar:warinstallinstall:installdeploydeploy:deploy经测试,
1.当pom中不增加resources配置时,
- 执行process-resources,class文件夹下只包含src/main/resources下的文件
- 执行compile,class文件夹下包含src/main/resources下的文件与src/main/java下的*.class文件,丢失src/main/java下的*.properties文件
2.当pom中增加resources配置时
- 执行process-resources,class文件夹下只包含src/main/resources下的文件与src/main/java下的*.properties文件
- 执行compile,class文件夹下包含src/main/resources下的文件与src/main/java下的*.class文件与*.properties文件
0 0
- Maven 打包时丢失properties文件
- Maven 打包时丢失properties文件
- Maven 打包时丢失properties文件
- Maven 打包时丢失properties文件
- Maven 打包时,src/main/java路径下的properties文件偶尔丢失
- Maven打包丢掉properties文件的问题
- eclipse web项目用maven打war包丢失.xml文件,丢失.properties文件
- maven install 打包的apk,so文件丢失
- maven 打包时动态替换properties资源文件中的配置值
- maven 打包时动态替换properties,xml资源文件中的配置值
- maven 根据P参数值打包动态修改properties文件中值或一定properties
- maven 根据P参数值打包动态修改properties文件中值或一定properties
- java修改properties文件 丢失内容
- maven工程打包后 properties未能读到pom properties
- maven: 资源文件打包
- Maven 选择文件打包
- Maven 打包时排除不想打包的文件&跳过测试
- Maven 打包时排除不想打包的文件&跳过测试
- 乐观锁与悲观锁区别
- json 解析 数组中的对象
- 【笔试/面试】—— 有向无环图(DAG)的最短路径问题(动态规划)
- namespace中配iptables规则注意事项
- HDU 4848 Wow! Such Conquering! 深搜+强剪枝
- Maven 打包时丢失properties文件
- MySQL6.0安装失败的解决方案
- Material Design入门(二)
- nginx下发布Apache web工程出现502
- 关于初学JAVA的第一次代码,IF从句,决赛赛选,慕课网的题。
- ActiveMQ实现负载均衡+高可用部署方案
- KMP算法
- cocos2d-lua04第一个工程
- MP4 info查看moov头位置