简体   繁体   English

无法解决maven依赖:无法找到javax.persistence:ejb:jar:3.0-public-draft-20060327

[英]Cannot resolve maven dependency: Failure to find javax.persistence:ejb:jar:3.0-public-draft-20060327

I'm trying to resurrect an old project. 我正试图复活一个项目。 I wanted to use Maven to manage dependencies/build/etc., and I got pretty far, but now I'm running into an error that I can't seem to resolve, and that I can't seem to find anything about: 我想使用Maven来管理依赖项/ build / etc。我已经相当远了,但现在我遇到了一个我似乎无法解决的错误,而且我似乎无法找到任何关于:

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/ ) 无法在项目scanit上执行目标:无法解析项目net.cbojar的依赖项:scanit:jar:0.2:无法在maven2中找到工件javax.persistence:ejb:jar:3.0-public-draft-20060327( http:// repo1.maven.org/maven2/

It wants to download a ejb-3.0-public-draft-20060327.jar file, but that file does not exist in the repo . 它想下载一个ejb-3.0-public-draft-20060327.jar文件,但该文件在repo中不存在

I'm relatively new to maven, and I wanted to use this as practice, but I have now painted myself into a corner. 我对maven比较陌生,我想把它作为练习,但我现在把自己画成了一个角落。 Below is my pom.xml file. 下面是我的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>

Given that you are converting to Maven an existing project, you should respect the original dependencies. 鉴于您要将Maven转换为现有项目,您应该尊重原始依赖项。 That means adding as a Maven dependency the exact same version of the original dependencies and excluding unused transitive dependency (since the original project doesn't need it and it works correctly then we can safely exclude them from the pom). 这意味着添加作为Maven依赖项的原始依赖项的完全相同版本并排除未使用的传递依赖项(因为原始项目不需要它并且它正常工作然后我们可以安全地将它们从pom中排除)。

It turns out that javax.persistence:ejb:jar:3.0-public-draft-20060327 is a transitive dependency of org.hibernate:hibernate-annotations:3.1beta9 . 事实证明, javax.persistence:ejb:jar:3.0-public-draft-20060327org.hibernate:hibernate-annotations:3.1beta9的传递依赖org.hibernate:hibernate-annotations:3.1beta9 If the original project doesn't need it, you can exclude it from the pom like this: 如果原始项目不需要它,您可以将其从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>

Remove your 删除你的

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

And use: 并使用:

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-annotations</artifactId>
    <version>3.5.6-Final</version>
</dependency>

That is the dependency causing you that problem. 那是导致你这个问题的依赖。 It is from 2006. I also recommend you to update your dependencies version to the most up to date. 它是从2006年开始的。我还建议您将依赖项版本更新到最新版本。

EDIT 编辑

As such an upgrade may break your code, and without further details, you should probably stick with a version closer to the one you are trying to use. 因为这样的升级可能会破坏您的代码,并且没有进一步的细节,您应该坚持使用更接近您尝试使用的版本的版本。

Check here for all hibernate-annotations versions available in maven repo. 点击此处查看maven repo中提供的所有hibernate-annotations版本。

You maybe need this dependecy declaration inside your project pom.xml: 您可能需要在项目pom.xml中使用此依赖声明:

    <dependency>
        <groupId>javax.persistence</groupId>
        <artifactId>ejb-3.0-public-draft</artifactId>
        <version>20050627</version>
        <type>pom</type>
    </dependency>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM