码迷,mamicode.com
首页 > 编程语言 > 详细

maven 打包 java中的配置文件

时间:2017-08-07 22:14:31      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:tor   写法   打包   目录   位置   http   pom.xml文件   资源   false   

转发地址 http://www.cnblogs.com/liuzy2014/p/5981824.html

一般情况下,我们用到的资源文件(各种xml,properites,xsd文件等)都放在src/main/resources下面,利用maven打包时,maven能把这些资源文件打包到相应的jar或者war里。 有时候,比如mybatis的mapper.xml文件,我们习惯把它和Mapper.java放一起,都在src/main/java下面,这样利用maven打包时,就需要修改pom.xml文件,来把mapper.xml文件一起打包进jar或者war里了,否则,这些文件不会被打包的。(maven认为src/main/java只是java的源代码路径)。网络上有很多方法,我大概试了下,几种方法都可以,可以任选一种即可。 否则打出来的war包是没有mapper.xml的。 方法1,其中**/*这样的写法,是为了保证各级子目录下的资源文件被打包。 Xml代码 收藏代码 <build> <finalName>test</finalName> <!-- 这样也可以把所有的xml文件,打包到相应位置。 <resources> <resource> <directory>src/main/resources</directory> <includes> <include>**/*.properties</include> <include>**/*.xml</include> <include>**/*.tld</include> </includes> <filtering>false</filtering> --filtering是表示配置文件中包括${}这种动态变更要不要替换成真实值,true表示替换,并且将该文件打包。false表示不替换。但是include一旦写上就肯定会将配置文件包含进war中 </resource> <resource> <directory>src/main/java</directory> <includes> <include>**/*.properties</include> <include>**/*.xml</include> <include>**/*.tld</include> </includes> <filtering>false</filtering> </resource> </resources> </build>

maven 打包 java中的配置文件

标签:tor   写法   打包   目录   位置   http   pom.xml文件   资源   false   

原文地址:http://www.cnblogs.com/juniorMa/p/7301208.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!