1、更新eclipse的classpath加入新依賴
1、在dependencyManagement裏面加入包括版本在內的依賴信息,如: <dependency> <groupId>joda-time</groupId> <artifactId>joda-time</artifactId>
<version>1.6.2</version>
</dependency>
2、在同級的dependencies節點裏面加入該依賴,如: <dependency> <groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
</dependency>
3、使用mvn eclipse:clean刪除當前的工程配置文件,並用mvn eclipse:eclipse重新生成。
4、導入或刷新該eclipse工程。
問題:Project configuration is not up-to-date with pom.xml
導入maven工程後,出現如下錯誤:
Description Resource Path Location Type
Project configuration is not up-to-date with pom.xml. Run project configuration update rdc line 1 Maven Configuration Problem
解決辦法就是:
右鍵項目,【Maven】--》【Update Project Configuration...】即可。。。
3、如何修改默認GBK的資源過濾
Using platform encoding (GBK actually) to copy filtered resources
需要指定字符集: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>2.2</version> <configuration>
<encoding>UTF-8</encoding> </configuration>
</plugin>
4、不支持範型的JDK版本問題
maven打包時始終出現TripApplyAction.java:[267,6]-source 1.3中不支持泛型(請使用-source 5或更高版本以啓用泛型)Map<String, Object> map = new HashMap<String, Object>();
解決方法,指定JDK版本:
在pom.xml文件中加入下一面一段語句來指定所用的版本,儘管在eclipse中配置了正確的“Build Path”: <build> <plugins> <plugin>
<artifactId>maven-compiler-plugin</artifactId> <configuration> <target>1.5</target> <source>1.5</source> <encoding>UTF-8</encoding> </configuration> </plugin> </plugins> </build>
重新運行mvn clean eclipse:eclipse -Dmaven.test.skip=true,接着mvn package,問題解決。
5、如何在使用命令方式下載依賴的同時下載源碼
1. 使用maven命令:mvn dependency:sources 下載依賴包的源代碼。
2. 使用參數: -DdownloadSources=true 下載源代碼jar。 -DdownloadJavadocs=true 下載javadoc包。
6、maven打包,忽略test的參數
mvn -Dmaven.test.failure.ignore=true package mvn -Dmaven.test.skip=true clean package
7、web.xml which will be ignored
[WARNING] Warning: selected war files include a WEB-INF/web.xml which will be ignored (webxml attribute is missing from war task, or ignoreWebxml attribute is specified as 'true')
在使用Maven 編譯項目的時候會出現
[WARNING] Warning: selected war files include a WEB-INF/web.xml which will be ignored
解決方法:
<plugin>
<groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.1.1</version> <configuration>
<!-- http://maven.apache.org/plugins/maven-war-plugin/ --> <packagingExcludes>WEB-INF/web.xml</packagingExcludes> </configuration> </plugin>
9、Maven3.04暫時不支持Servlet3的無web.xml形式
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war
(default-war) on project prospringmvc01: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) ->