2014-02-04 2 views
0

Я недавно устал исправлять проблему с зависимостями maven в моем веб-проекте java, и я удалил все вещи из папки репозитория, после чего я сделал «проект обновления maven» в eclipse и проблема была исправлена, однако возникла другая ошибка. Метод, который я использовал, createNamedQuery(String, Class<T>) больше не существует в интерфейсе javax.persistence.EntityManager. Я провел некоторое исследование, и я подозреваю, что maven изменила версию реализации JPA на JPA 1.0, что очень раздражает, и я даже не знаю, как это исправить. Я ничего не менял в pom.xml, единственное изменение, которое я заметил, состоит в том, что пакет javax.persistence теперь поступает из jjb3 из jboss-as-connector maven artifact. Как я могу это исправить?javax.persistence.EntityManager отсутствует метод

ПРОБЛЕМА: Я только узнал, что ejb3-persistence исходит из пакета спящего режима.

EDIT:

pom.xml файл:..

... 
<properties> 
    <jboss.provided.jar>compile</jboss.provided.jar> 
</properties> 

<!-- JBoss repository for JMS stuff --> 
<repositories> 
    <repository> 
     <id>JBoss repository</id> 
     <url>http://repository.jboss.org/nexus/content/groups/public/</url> 
    </repository> 
</repositories> 

<dependencies> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.mockito</groupId> 
     <artifactId>mockito-all</artifactId> 
     <version>1.9.5</version> 
     <scope>test</scope> 
    </dependency> 
    <!-- Provides better parameterized tests than those provided by junit --> 
    <dependency> 
     <groupId>pl.pragmatists</groupId> 
     <artifactId>JUnitParams</artifactId> 
     <version>1.0.2</version> 
     <scope>test</scope> 
    </dependency> 
    <!-- Required for SpringJUnit4ClassRunner in IntegrationTests --> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-test</artifactId> 
     <version>${org.springframework.version}</version> 
     <scope>test</scope> 
    </dependency> 
    <!-- Required for SpringockitoContextLoader in IntegrationTests --> 
    <dependency> 
     <groupId>org.kubek2k</groupId> 
     <artifactId>springockito-annotations</artifactId> 
     <version>1.0.8</version> 
     <scope>test</scope> 
    </dependency> 
    <!-- Required for created the hsql database in IntegrationTests --> 
    <dependency> 
     <groupId>org.hsqldb</groupId> 
     <artifactId>hsqldb</artifactId> 
     <version>2.3.1</version> 
     <scope>test</scope> 
    </dependency> 
    <!-- Required for Selenium WebDriver automated tests --> 
    <dependency> 
     <groupId>org.seleniumhq.selenium</groupId> 
     <artifactId>selenium-java</artifactId> 
     <version>2.33.0</version> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>xml-apis</groupId> 
     <artifactId>xml-apis</artifactId> 
     <version>1.4.01</version> 
     <scope>test</scope> 
    </dependency> 

    THIS IS PROBABLY THE ROOT OF ALL EVIL 
    <!-- JBoss Seam - stuff for JMS Queue on JBoss --> 
    <dependency> 
     <groupId>org.jboss.jbossas</groupId> 
     <artifactId>jboss-as-connector</artifactId> 
     <version>6.1.0.Final</version> 
    </dependency> 


    <!-- Required when running the integration tests --> 
    <dependency> 
     <groupId>javax.servlet</groupId> 
     <artifactId>servlet-api</artifactId> 
     <version>2.5</version> 
     <scope>provided</scope> 
    </dependency> 

    <!-- aspectjrt and aspectjweaver both required for @Autowired annotation 
     to work --> 
    <dependency> 
     <groupId>org.aspectj</groupId> 
     <artifactId>aspectjrt</artifactId> 
     <version>1.7.3</version> 
    </dependency> 
    <dependency> 
     <groupId>org.aspectj</groupId> 
     <artifactId>aspectjweaver</artifactId> 
     <version>1.7.3</version> 
    </dependency> 

    <!-- Required for spring bean proxying to work in integration tests --> 
    <dependency> 
     <groupId>cglib</groupId> 
     <artifactId>cglib-nodep</artifactId> 
     <version>2.1_3</version> 
    </dependency> 

    <!-- Spring --> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-core</artifactId> 
     <version>${org.springframework.version}</version> 
    </dependency> 
    <!-- Required for @RequestMapping annotation --> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-web</artifactId> 
     <version>${org.springframework.version}</version> 
     <type>jar</type> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-tx</artifactId> 
     <version>${org.springframework.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-webmvc</artifactId> 
     <version>${org.springframework.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-aop</artifactId> 
     <version>${org.springframework.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-orm</artifactId> 
     <version>${org.springframework.version}</version> 
    </dependency> 

    <!-- Use the same hibernate and Mysql versions as those on the JBoss server --> 
    <dependency> 
     <groupId>org.hibernate</groupId> 
     <artifactId>hibernate-entitymanager</artifactId> 
     <version>${org.hibernate.version}</version> 
     <scope>${jboss.provided.jar}</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.hibernate</groupId> 
     <artifactId>hibernate-validator</artifactId> 
     <version>5.0.1.Final</version> 
     <scope>${jboss.provided.jar}</scope> 
    </dependency> 
    <dependency> 
     <groupId>mysql</groupId> 
     <artifactId>mysql-connector-java</artifactId> 
     <version>5.1.22</version> 
     <scope>${jboss.provided.jar}</scope> 
    </dependency> 

    <!-- Use slf4j and log4j for logging --> 
    <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>slf4j-api</artifactId> 
     <version>1.7.5</version> 
    </dependency> 
    <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>slf4j-log4j12</artifactId> 
     <version>1.7.5</version> 
    </dependency> 
    <dependency> 
     <groupId>log4j</groupId> 
     <artifactId>log4j</artifactId> 
     <version>1.2.14</version> 
     <scope>${jboss.provided.jar}</scope> 
    </dependency> 

    <!-- Required for communication with exchange --> 
    <dependency> 
     <groupId>com.microsoft.ewsjavaapi</groupId> 
     <artifactId>exchange-ws-api</artifactId> 
     <version>1.1.5.2</version> 
    </dependency> 
    <dependency> 
     <groupId>commons-httpclient</groupId> 
     <artifactId>commons-httpclient</artifactId> 
     <version>3.1</version> 
    </dependency> 
    <dependency> 
     <groupId>commons-codec</groupId> 
     <artifactId>commons-codec</artifactId> 
     <version>1.4</version> 
    </dependency> 
    <dependency> 
     <groupId>commons-logging</groupId> 
     <artifactId>commons-logging</artifactId> 
     <version>1.1.1</version> 
    </dependency> 
    <dependency> 
     <groupId>jcifs</groupId> 
     <artifactId>jcifs</artifactId> 
     <version>1.3.17</version> 
    </dependency> 
    <!-- end of dependencies for exchange --> 

    <!-- Required for FileUtils --> 
    <dependency> 
     <groupId>commons-io</groupId> 
     <artifactId>commons-io</artifactId> 
     <version>2.4</version> 
    </dependency> 

    <!-- Required for StringUtils --> 
    <dependency> 
     <groupId>org.apache.commons</groupId> 
     <artifactId>commons-lang3</artifactId> 
     <version>3.1</version> 
    </dependency> 
</dependencies> 
<build> 
    <finalName>cat-webapp</finalName> 

... 
+1

Можете выложить свой 'pom.xml', пожалуйста? – Stephan

+0

Я попытаюсь удалить все ненужные вещи, потому что это почти 400 строк длиной ... дайте 2 минуты. – Lucas

+0

другой EDIT: jjb3 jar поставляется из пакета спящего режима – Lucas

ответ

0

Заменить эту зависимость:

<dependency> 
    <groupId>org.jboss.jbossas</groupId> 
    <artifactId>jboss-as-connector</artifactId> 
    <version>6.1.0.Final</version> 
</dependency> 

с

<dependency> 
    <groupId>org.jboss.as</groupId> 
    <artifactId>jboss-as-connector</artifactId> 
    <version>7.1.1.Final</version> 
</dependency> 

вы получите интерфейс EntityManager из hibernate-jpa-2.0-api с методом createNamedQuery.

+0

Это сработало, однако кажется, что у меня есть другие проблемы с моим pom.xml. Спасибо :) – Lucas

+0

@ Лукас Добро пожаловать;) – Stephan

0
  1. Чтобы узнать, какие библиотеки этот класс приходит от просто позвонить Thread.currentThread() getContextClassLoader() getResource («javax/persistence/EntityManager.class»)

  2. Чтобы узнать, какая зависимость это от вызова mvn dependency: tre е

Смежные вопросы