Java Maven/mvn 警告 - 强烈建议修复这些问题,因为它们会威胁到您构建的稳定性
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23708691/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Maven/mvn warnings - It is highly recommended to fix these problems because they threaten the stability of your build
提问by Erran Morad
This question is NOT about the Spring framework or J2EE as such.
这个问题与 Spring 框架或 J2EE 本身无关。
As per my book, I have a Spring project in eclipse-jee. It tells me to build the project with maven. I am new to maven and I don't know what I am doing with it.
根据我的书,我在 eclipse-jee 中有一个 Spring 项目。它告诉我用 maven 构建项目。我是 maven 的新手,我不知道我在用它做什么。
So, I used windows cmd to get to my project folder in eclipse and executed mvn package -DskipTests
. Now, this succeeds with a BUILD SUCCESS
message, but it also gives me warnings
given below.
因此,我使用 windows cmd 进入我在 eclipse 中的项目文件夹并执行mvn package -DskipTests
. 现在,这通过一条BUILD SUCCESS
消息成功,但它也给了我下面给出的警告。
Please tell me why the warnings occur and how can ignoring them could affect the code in the future ?
请告诉我为什么会出现这些警告以及如何忽略它们会影响将来的代码?
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for
com.perfmath.spring:soba:war:4
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be
unique: org.apache.httpcomponents:httpclient:jar -> version 4.1.2 vs 4.0.3 @ li
ne 229, column 15
[WARNING] 'build.plugins.plugin.version' for org.codehaus.mojo:tomcat-maven-plug
in is missing. @ line 46, column 12
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten t
he stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support buildin
g such malformed projects.
[WARNING]
Dependencies section of my pom.xml -
我的 pom.xml 的依赖项部分 -
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>${spring-security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>${spring-security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>${spring-security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-acl</artifactId>
<version>${spring-security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core-tiger</artifactId>
<version>2.0.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-crypto</artifactId>
<version>${spring-security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-mock</artifactId>
<version>${spring-mock.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<!-- Spring webflow -->
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>org.springframework.webflow</groupId>
<artifactId>spring-binding</artifactId>
<version>${spring.webflow.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.webflow</groupId>
<artifactId>spring-js</artifactId>
<version>${spring.webflow.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.webflow</groupId>
<artifactId>spring-webflow</artifactId>
<version>${spring.webflow.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.Hymanson</groupId>
<artifactId>Hymanson-mapper-asl</artifactId>
<version>${Hymanson-mapper-asl.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>${jaxb-api.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibenate.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibenate.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
<version>${hibenate.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.3.1.Final</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.6</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>commons-pool</groupId>
<artifactId>commons-pool</artifactId>
<version>20030825.183949</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.0.3</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.9</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8</version>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${aspectj.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>2.7.5</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2</version>
</dependency>
</dependencies>
采纳答案by Erran Morad
Open your pom file. Look at the missing classes in your error. In your pom file, find the dependencies which would contain those classes and then read the next steps.
打开你的 pom 文件。查看错误中缺少的类。在您的 pom 文件中,找到将包含这些类的依赖项,然后阅读后续步骤。
You have two warnings. The first warns you that you have the same dependency declared twice, but with different versions. When you are using classes from org.apache.httpcomponents:httpclient, how is Maven to know you want classes from 4.1.2, or 4.0.3? Delete the dependency tag for one of them.
你有两个警告。第一个警告您声明了两次相同的依赖项,但版本不同。当您使用 org.apache.httpcomponents:httpclient 中的类时,Maven 如何知道您想要 4.1.2 或 4.0.3 中的类?删除其中之一的依赖项标记。
The second warning says that the plugin org.codehaus.mojo:tomcat-maven-plugin is declared without a version. When you declare a dependency or plugin, you should always use a version as well, unless the version is inherited from a pluginManagement or dependencyManagement section. To fix this problem, find the plugin under <build><plugins>
, and explicitly set a version to use.
第二个警告说插件 org.codehaus.mojo:tomcat-maven-plugin 被声明为没有版本。当您声明依赖项或插件时,您也应该始终使用版本,除非该版本是从 pluginManagement 或 dependencyManagement 部分继承的。要解决此问题,请在 下找到插件<build><plugins>
,并明确设置要使用的版本。
You can get your version number for eclipse (if you installed it) using - Click Window –> Preferences –> Maven –> Installation . It will show you installation window with Maven version.
您可以使用 - 单击 Window –> Preferences –> Maven –> Installation 获取 Eclipse 的版本号(如果已安装)。它将显示带有 Maven 版本的安装窗口。
回答by Warren Dew
The warnings occur because the .pom files for your build - your project and its dependencies - contain information that appears to conflict or is missing. The maven implementation happens to run anyway, but they might want to clean up a future version of maven to address the issues more cleanly, at which point it might not handle these issues any more.
出现警告是因为您构建的 .pom 文件(您的项目及其依赖项)包含似乎冲突或丢失的信息。无论如何,maven 实现碰巧运行,但他们可能希望清理 maven 的未来版本以更干净地解决问题,此时它可能不再处理这些问题。
This is unlikely to cause a problem until you update maven versions. Given your description of your experience with maven, I'd recommend leaving it alone until you have more experience and can address it comfortably. In the meantime, the warnings will be there to remind you.
在您更新 Maven 版本之前,这不太可能导致问题。鉴于您对使用 maven 的经验的描述,我建议您不要管它,直到您有更多的经验并且可以轻松地解决它。同时,警告将在那里提醒您。
回答by Mr.Q
most of the time these warningns pop up because, when you where defining your dependencies in your pom file you forgot to specify the attributes needed for depenceny (artifactID, groupId, version). usually this dosent make any problem unless you have to use an specific version of a dependency.
大多数情况下,这些警告会弹出,因为当您在 pom 文件中定义依赖项时,您忘记指定依赖项所需的属性(工件 ID、组 ID、版本)。通常这不会产生任何问题,除非您必须使用特定版本的依赖项。