gpt4 book ai didi

java - 无法解析 Maven 依赖项 : Failure to find javax. 持久性 :ejb:jar:3. 0-public-draft-20060327

转载 作者:行者123 更新时间:2023-11-29 05:00:14 25 4
gpt4 key购买 nike

我正在尝试恢复一个 项目。我想使用 Maven 来管理依赖项/构建/等等,我已经走得很远了,但现在我遇到了一个我似乎无法解决的错误,而且我似乎找不到任何关于:

Failed to execute goal on project scanit: Could not resolve dependencies for project net.cbojar:scanit:jar:0.2: Could not find artifact javax.persistence:ejb:jar:3.0-public-draft-20060327 in maven2 (http://repo1.maven.org/maven2/)

它想要下载一个 ejb-3.0-public-draft-20060327.jar 文件,但是那个文件 does not exist in the repo .

我对 maven 比较陌生,我想用它来练习,但我现在把自己逼到了一个角落。下面是我的 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>net.cbojar</groupId>
<artifactId>scanit</artifactId>
<version>1.0</version>

<build>
<sourceDirectory>${basedir}/src</sourceDirectory>
<testSourceDirectory>${basedir}/test</testSourceDirectory>
<outputDirectory>${basedir}/bin/classes</outputDirectory>
<testOutputDirectory>${basedir}/bin/test</testOutputDirectory>
<directory>${basedir}/bin</directory>
<finalName>${project.artifactId}-${project.version}</finalName>

<plugins>
<plugin>
<!-- Build an executable JAR -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>net.cbojar.scanit.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>

<repositories>
<repository>
<id>maven2</id>
<name>Central Maven Repository</name>
<url>http://repo1.maven.org/maven2/</url>
<layout>default</layout>
</repository>

<!--These are needed for Swing/Netbeans -->
<repository>
<id>maven2-repository.netbeans.maven2</id>
<name>Netbeans Maven Repository</name>
<url>http://bits.netbeans.org/maven2/</url>
<layout>default</layout>
</repository>
</repositories>

<dependencies>
<!-- TODO: Update to JUnit 4 -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.netbeans.external</groupId>
<artifactId>AbsoluteLayout</artifactId>
<version>RELEASE701</version>
</dependency>

<dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
<version>2.7.6</version>
</dependency>

<dependency>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
<version>1.5.3</version>
</dependency>

<dependency>
<groupId>asm</groupId>
<artifactId>asm-attrs</artifactId>
<version>1.5.3</version>
</dependency>

<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.1_3</version>
</dependency>

<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>2.1.1</version>
</dependency>

<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.0.4</version>
</dependency>

<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.2.2.0</version>
</dependency>

<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>

<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>1.2.3</version>
</dependency>

<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.23</version>
</dependency>

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
<version>3.2.1.ga</version>
</dependency>

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.1beta9</version>
</dependency>

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>3.1.0.GA</version>
</dependency>

<dependency>
<groupId>hibernate</groupId>
<artifactId>hibernate-tools</artifactId>
<version>2.1.3</version>
</dependency>

<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>1.1</version>
</dependency>

<dependency>
<groupId>net.sf.jtidy</groupId>
<artifactId>jtidy</artifactId>
<version>r938</version>
</dependency>

<dependency>
<groupId>org.netbeans</groupId>
<artifactId>lib</artifactId>
<version>3.6</version>
</dependency>

<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
</dependency>

<dependency>
<groupId>org.swinglabs</groupId>
<artifactId>swing-layout</artifactId>
<version>1.0.3</version>
</dependency>
</dependencies>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
</project>

最佳答案

鉴于您要将现有项目转换为 Maven,您应该尊重原始依赖项。这意味着将与原始依赖项完全相同的版本添加为 Maven 依赖项,并排除未使用的传递依赖项(因为原始项目不需要它并且它可以正常工作,所以我们可以安全地将它们从 pom 中排除)。

事实证明,javax.persistence:ejb:jar:3.0-public-draft-20060327org.hibernate:hibernate-annotations:3.1beta9 的传递依赖>。如果原来的项目不需要它,你可以像这样从pom中排除它:

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.1beta9</version>
<exclusions>
<exclusion>
<groupId>javax.persistence</groupId>
<artifactId>ejb</artifactId>
<exclusion>
</exclusions>
</dependency>

关于java - 无法解析 Maven 依赖项 : Failure to find javax. 持久性 :ejb:jar:3. 0-public-draft-20060327,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32340050/

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