gpt4 book ai didi

java - Maven 不支持 Maven 依赖插件

转载 作者:行者123 更新时间:2023-11-29 07:55:53 25 4
gpt4 key购买 nike

我试图从一本书中下载 Spring/Java 代码来运行他们的代码并进行测试,但不幸的是我遇到了错误,

我看到这是一个常见错误,但没有看到我的 pom 文件的修复程序,

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.apress.springrecipes</groupId>
<artifactId>core</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>springintro</artifactId>
<name>Introduction to Spring</name>
<dependencies>

<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.javaee</groupId>
<artifactId>jboss-jca-api</artifactId>
</dependency>

</dependencies>


</project>

错误

Jul 17, 2013 3:51:20 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@be41ec: startup date [Wed Jul 17 15:51:20 EDT 2013]; root of context hierarchy
Jul 17, 2013 3:51:20 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [beans.xml]
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [beans.xml]; nested exception is java.io.FileNotFoundException: class path resource [beans.xml] cannot be opened because it does not exist
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:341)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:212)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:126)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:92)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:465)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:395)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.apress.springrecipes.hello.Main.main(Main.java:10)
Caused by: java.io.FileNotFoundException: class path resource [beans.xml] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:141)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:328)
... 13 more

Pom文件错误:

maven-dependency-plugin (goals "copy-dependencies", "unpack") is not supported by m2e.
maven-resources-plugin prior to 2.4 is not supported by m2e. Use maven-resources-plugin version 2.4 or later.

最佳答案

@Pace 所说的完全正确,我相信 OP 应该尝试理解 m2e 在做什么。 我个人讨厌 0.10 之后 m2e 的行为,为此他们引入了连接器概念。这个概念很好,但是告诉 Eclipse 如何对不受支持的插件使用react的方法是严重污染 POM,这在我看来很糟糕。切换回旧的 M2E 版本可能会让您的生活更轻松,尽管您会失去一些功能。

从您引用的错误消息回到您的问题:

maven-resources-plugin prior to 2.4 is not supported by m2e. Use maven-resources-plugin version 2.4 or later.

在我看来,m2e 确实支持 maven-resources-plugin >= 2.4(我不确定,我以前没有遇到过与您类似的问题)。尝试在您的 POM 中使用较新版本(2.4 或更高版本,最新版本为 2.6)的 maven-resources-plugin,M2E 可能会为您获取设置。

<project>
...
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
</plugin>
</plugins>
....
</pluginManagement>
....
</build>
</project>

标记您使用的插件版本始终是一个好习惯。这导致更“可重现”的构建。

关于java - Maven 不支持 Maven 依赖插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17709651/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com