错误:无法解析依赖项(maven javaEE项目)

时间:2011-12-22 22:46:06

标签: java-ee netbeans maven-2 netbeans7.0

我有一个maven Entreprise应用程序项目。我在EJB项目中创建了持久性单元,实体类和EJB会话Bean。我尝试构建项目时遇到此错误:

  

无法在项目Blog6-ejb上执行目标:无法解决   项目com.mycompany的依赖项:Blog6-ejb:ejb:1.0-SNAPSHOT:The   以下工件无法解决:   org.eclipse.persistence:的EclipseLink:罐子:2.2.0,   org.eclipse.persistence:javax.persistence:罐子:2.0.3,   org.eclipse.persistence:org.eclipse.persistence.jpa.modelgen.processor:罐子:2.2.0:   找不到org.eclipse.persistence:eclipselink:jar:2.2.0 in   http://ftp.ing.umu.se/mirror/eclipse/rt/eclipselink/maven.repo是   缓存在本地存储库中,不会重新尝试解析   直到eclipselink的更新间隔已经过去或更新为止   强迫 - > [帮助1]

这是pom.xml中的代码

    <?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<artifactId>Blog6</artifactId>
<groupId>com.mycompany</groupId>
<version>1.0-SNAPSHOT</version>
</parent>

<groupId>com.mycompany</groupId>
<artifactId>Blog6-ejb</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>ejb</packaging>

<name>Blog6-ejb</name>

<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<netbeans.hint.deploy.server>gfv3ee6</netbeans.hint.deploy.server>
</properties>

<dependencies>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.0.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa.modelgen.processor</artifactId>
<version>2.2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<version>2.3</version>
<configuration>
<ejbVersion>3.1</ejbVersion>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>6.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<url>http://ftp.ing.umu.se/mirror/eclipse/rt/eclipselink/maven.repo</url>
<id>eclipselink</id>
<layout>default</layout>
<name>Repository for library Library[eclipselink]</name>
</repository>
</repositories>
</project>

的persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="com.mycompany_Blog6-ejb_ejb_1.0-SNAPSHOTPU" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/sample</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.ddl-generation" value="create-tables"/>
</properties>
</persistence-unit>
</persistence>

感谢您的帮助

2 个答案:

答案 0 :(得分:6)

  

据报道,对Maven存储库使用Eclipse镜像会导致报告为不可用于本地maven存储库损坏的工件产生各种问题。因此,不要使用镜像下载URL:http://www.eclipse.org/downloads/download.php?r=1&nf=1&file=/rt/eclipselink/maven.repo,建议您使用未镜像的URL直接访问Eclipse下载站点上的EclipseLink Maven存储库:http://download.eclipse.org/rt/eclipselink/maven.repo

来源&amp;更多信息:http://wiki.eclipse.org/EclipseLink/Maven包括如何编辑您的pom文件以指向不同的仓库。

答案 1 :(得分:0)

如果要创建启用了持久性的简单Java EE 6应用程序,可以从提供的工件开始,例如这个:

mvn archetype:generate -DarchetypeArtifactId=jboss-javaee6-webapp -DarchetypeGroupId=org.jboss.weld.archetypes -DarchetypeVersion=1.0.1.CR1 -DarchetypeRepository=central

或仅适用于简单的servlet容器:

mvn archetype:generate -DarchetypeArtifactId=jboss-jsf-weld-servlet-webapp -DarchetypeGroupId=org.jboss.weld.archetypes -DarchetypeVersion=1.0.1.Beta1 -DarchetypeRepository=central

在此处找到:http://seamframework.org/Documentation/CDIQuickstartForMavenUsers

生成项目后,将其作为现有maven项目导入到您选择的IDE中。

相关问题