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

时间:2015-09-01 20:07:39

标签: java maven jpa

我试图恢复项目。我想使用Maven来管理依赖项/构建/等等,而且我已经相当远了,但现在我遇到了一个我无法解决的错误,而且我无法解决这个问题。似乎找到了一些关于:

  

无法在项目scanit上执行目标:无法解析项目net.cbojar的依赖项:scanit:jar:0.2:无法在maven2中找到工件javax.persistence:ejb:jar:3.0-public-draft-20060327({ {3}})

它想要下载ejb-3.0-public-draft-20060327.jar文件,但该文件http://repo1.maven.org/maven2/

我对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>

3 个答案:

答案 0 :(得分:2)

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

事实证明 Now we are use BETWEEN for getting august month report 1 to 31. $var2=' 2015-08-10'; $date2 = str_replace('/', '-', $var2); // First day of the month. $From=date('Y-m-01', strtotime($date2)); // Last day of the month. $To=date('Y-m-t', strtotime($date2)); javax.persistence:ejb:jar:3.0-public-draft-20060327的传递依赖。如果原始项目不需要它,您可以将其从pom中排除:

org.hibernate:hibernate-annotations:3.1beta9

答案 1 :(得分:1)

删除

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

并使用:

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

这是造成你这个问题的依赖。它是从2006年开始的。我还建议您将依赖项版本更新到最新版本。

修改

因为这样的升级可能会破坏您的代码,并且没有进一步的细节,您应该坚持使用更接近您尝试使用的版本。

Check here适用于maven repo中的所有hibernate-annotations版本。

答案 2 :(得分:0)

您可能需要在项目pom.xml中使用此依赖声明:

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