前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >maven使用常见问题 转

maven使用常见问题 转

作者头像
用户2603479
发布2018-08-15 16:26:17
8240
发布2018-08-15 16:26:17
举报
文章被收录于专栏:JAVA技术站JAVA技术站

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工程。

2、工程配置未使用pom.xml更新问题:

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包。

7、maven打包,忽略test的参数mvn -Dmaven.test.failure.ignore=true package mvn -Dmaven.test.skip=true clean package

8、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 ask, 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 (orpre-existing WEB-INF/web.xml if executing in update mode) ->

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2014/07/08 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档