maven 使用问题记录

来源:互联网 发布:淘宝网天天特价连衣裙 编辑:程序博客网 时间:2024/05/22 23:27

maven 插件

Author : Janloong Do_O

maven-compline-plugin 找不到jar包

使用maven管理idea的web项目时,如果引用了pom依赖之外的jar包,在使用maven-compline 时会出现找不到对应的jar包内容的编译错误。是因为maven在编译的时候默认没有编译pom以外的内容需要在pom中的plugin配置中添加额外的编译路径例:第三方jar包放在webroot/WEB-INF/下添加 编译参数设置, <extdirs>${basedir}/src/main/webapp/WEB-INF/lib</extdirs>

完整设置参照:

<plugin>    <groupId>org.apache.maven.plugins</groupId>    <artifactId>maven-compiler-plugin</artifactId>    <version>3.0</version>    <configuration>        <source>1.8</source>        <target>1.8</target>        <encoding>UTF-8</encoding>        <compilerArguments>            <verbose />            <extdirs>${basedir}/src/main/webapp/WEB-INF/lib</extdirs>            <bootclasspath>${java.home}/lib/rt.jar:${java.home}/lib/jce.jar</bootclasspath>        </compilerArguments>    </configuration></plugin>

maven 多profile 的filter properties 文件中文乱码问题

未使用filter注入配置文件的时候中文读取显示正常但通过filter注入时,属性文件却显示中文乱码,这里在maven插件配置编码正常的情况下,经过排查发现是在此注入条件下,java在读取配置文件的时候发生编码错误。解决方法为:读取配置文件的时候应该将流转换为UTF-8格式读取Properties prop=new Properties();prop.load(new InputStreamReader(Client.class.getClassLoader().getResourceAsStream("config.properties"), "UTF-8"));