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"));