2013-04-09 70 views
1

我開始querydsl使用MongoDB的, 我發現網絡上的一些例子,並試圖使用它, 我的pom.xml看起來像(也許有在版本中的一些錯誤。 ..):誤差querydsl和MongoDB:NoClassDefFoundError的謂詞

...

<!-- Versions --> 
    <properties> 
     <spring.version>3.2.1.RELEASE</spring.version> 
     <spring.data.jpa.version>1.2.0.RELEASE</spring.data.jpa.version> 
     <spring.data.mongo.version>1.0.3.RELEASE</spring.data.mongo.version> 
     <spring.amqp.version>1.0.0.RELEASE</spring.amqp.version> 
     <slf4j-version>1.6.1</slf4j-version> 
     <org.cloudfoundry-version>0.8.0</org.cloudfoundry-version> 
     <querydsl.version>2.3.3</querydsl.version> 
    </properties> 

<dependencies> 

    <!-- CloudFoundry --> 
    <dependency> 
     <groupId>org.cloudfoundry</groupId> 
     <artifactId>cloudfoundry-runtime</artifactId> 
     <version>${org.cloudfoundry-version}</version> 
    </dependency> 

    <!-- Spring Core --> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-core</artifactId> 
     <version>${spring.version}</version> 
     <type>jar</type> 
     <scope>compile</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-web</artifactId> 
     <version>${spring.version}</version> 
     <type>jar</type> 
     <scope>compile</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-tx</artifactId> 
     <version>${spring.version}</version> 
     <type>jar</type> 
     <scope>compile</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-webmvc</artifactId> 
     <version>${spring.version}</version> 
     <type>jar</type> 
     <scope>compile</scope> 
    </dependency> 

    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-context</artifactId> 
     <version>${spring.version}</version> 
    </dependency> 

    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-aop</artifactId> 
     <version>${spring.version}</version> 
    </dependency> 

    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-jdbc</artifactId> 
     <version>${spring.version}</version> 
     <type>jar</type> 
     <scope>compile</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-oxm</artifactId> 
     <version>${spring.version}</version> 
     <type>jar</type> 
     <scope>compile</scope> 
    </dependency> 

    <dependency> 
     <groupId>org.aspectj</groupId> 
     <artifactId>aspectjrt</artifactId> 
     <version>1.6.10</version> 
    </dependency> 

    <dependency> 
     <groupId>org.aspectj</groupId> 
     <artifactId>aspectjweaver</artifactId> 
     <version>1.6.10</version> 
    </dependency> 

    <!-- Cglib is a powerful, high performance and quality Code Generation 
     Library, It is used to extend JAVA classes and implements interfaces at runtime. --> 
    <dependency> 
     <groupId>cglib</groupId> 
     <artifactId>cglib-nodep</artifactId> 
     <version>2.2</version> 
     <type>jar</type> 
     <scope>compile</scope> 
    </dependency> 

    <!-- Querydsl --> 
    <dependency> 
     <groupId>com.mysema.querydsl</groupId> 
     <artifactId>querydsl-mongodb</artifactId> 
     <version>${querydsl.version}</version> 
     <optional>true</optional> 
     <exclusions> 
      <exclusion> 
       <groupId>com.google.code.morphia</groupId> 
       <artifactId>morphia</artifactId> 
      </exclusion> 
     </exclusions> 
    </dependency> 

    <dependency> 
     <groupId>com.mysema.querydsl</groupId> 
     <artifactId>querydsl-apt</artifactId> 
     <version>${querydsl.version}</version> 
     <scope>provided</scope> 
    </dependency> 

    <!-- Database pooling --> 
    <dependency> 
     <groupId>c3p0</groupId> 
     <artifactId>c3p0</artifactId> 
     <version>0.9.1.2</version> 
     <type>jar</type> 
     <scope>compile</scope> 
    </dependency> 

    <!-- Joda Time --> 
    <dependency> 
     <groupId>joda-time</groupId> 
     <artifactId>joda-time</artifactId> 
     <version>1.6.2</version> 
    </dependency> 

    <!-- Logger --> 
    <dependency> 
     <groupId>log4j</groupId> 
     <artifactId>log4j</artifactId> 
     <version>1.2.14</version> 
     <type>jar</type> 
     <scope>compile</scope> 
    </dependency> 

    <!-- apache commons --> 
    <dependency> 
     <groupId>commons-lang</groupId> 
     <artifactId>commons-lang</artifactId> 
     <version>2.6</version> 
    </dependency> 

    <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>slf4j-api</artifactId> 
     <version>${slf4j-version}</version> 
     <type>jar</type> 
     <scope>compile</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>slf4j-log4j12</artifactId> 
     <version>${slf4j-version}</version> 
     <type>jar</type> 
     <scope>compile</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>jcl-over-slf4j</artifactId> 
     <version>${slf4j-version}</version> 
     <type>jar</type> 
     <scope>compile</scope> 
    </dependency> 

    <!-- Javax Servlet. This needs to be included for runtime only! --> 
    <dependency> 
     <groupId>javax.servlet</groupId> 
     <artifactId>servlet-api</artifactId> 
     <version>2.5</version> 
     <scope>provided</scope> 
    </dependency> 

    <dependency> 
     <groupId>javax.servlet</groupId> 
     <artifactId>jstl</artifactId> 
     <version>1.1.2</version> 
    </dependency> 
    <dependency> 
     <groupId>taglibs</groupId> 
     <artifactId>standard</artifactId> 
     <version>1.1.2</version> 
    </dependency> 
    <dependency> 
     <groupId>javax.servlet</groupId> 
     <artifactId>jsp-api</artifactId> 
     <version>2.0</version> 
     <scope>provided</scope> 
    </dependency> 

    <!-- Data Mapper package is a high-performance data binding package built 
     on Jackson JSON processor --> 
    <dependency> 
     <groupId>org.codehaus.jackson</groupId> 
     <artifactId>jackson-mapper-asl</artifactId> 
     <version>1.8.0</version> 
     <type>jar</type> 
     <scope>compile</scope> 
    </dependency> 

    <!-- Jackson is a high-performance JSON processor (parser, generator) --> 
    <dependency> 
     <groupId>org.codehaus.jackson</groupId> 
     <artifactId>jackson-core-asl</artifactId> 
     <version>1.8.0</version> 
     <type>jar</type> 
     <scope>compile</scope> 
    </dependency> 

    <!-- Hibernate and JPA --> 
    <dependency> 
     <groupId>org.hibernate.java-persistence</groupId> 
     <artifactId>jpa-api</artifactId> 
     <version>2.0-cr-1</version> 
     <scope>compile</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.hibernate</groupId> 
     <artifactId>hibernate-entitymanager</artifactId> 
     <version>3.6.3.Final</version> 
     <scope>compile</scope> 
    </dependency> 

    <!-- Hibernate Validator --> 
    <dependency> 
     <groupId>org.hibernate</groupId> 
     <artifactId>hibernate-validator</artifactId> 
     <version>4.1.0.Final</version> 
    </dependency> 
    <dependency> 
     <groupId>javax.validation</groupId> 
     <artifactId>validation-api</artifactId> 
     <version>1.0.0.GA</version> 
    </dependency> 

    <!-- MySQL Connector --> 
    <dependency> 
     <groupId>mysql</groupId> 
     <artifactId>mysql-connector-java</artifactId> 
     <version>5.1.16</version> 
     <type>jar</type> 
     <scope>compile</scope> 
    </dependency> 

    <!-- MongoDB Java Driver --> 
    <dependency> 
     <groupId>org.mongodb</groupId> 
     <artifactId>mongo-java-driver</artifactId> 
     <version>2.7.1</version> 
     <type>jar</type> 
     <scope>compile</scope> 
    </dependency> 

    <!-- Spring Data JPA --> 
    <dependency> 
     <groupId>org.springframework.data</groupId> 
     <artifactId>spring-data-jpa</artifactId> 
     <version>${spring.data.jpa.version}</version> 
    </dependency> 

    <!-- Spring Data MongoDB --> 
    <dependency> 
     <groupId>org.springframework.data</groupId> 
     <artifactId>spring-data-mongodb</artifactId> 
     <version>${spring.data.mongo.version}</version> 
    </dependency> 

    <!-- Spring RabbitMQ --> 
    <dependency> 
     <groupId>org.springframework.amqp</groupId> 
     <artifactId>spring-rabbit</artifactId> 
     <version>${spring.amqp.version}</version> 
    </dependency> 

    <!-- Ehcache --> 
    <dependency> 
     <groupId>net.sf.ehcache</groupId> 
     <artifactId>ehcache-core</artifactId> 
     <version>2.4.5</version> 
    </dependency> 

後部署Web應用程序服務器我得到這個錯誤:

Caused by: java.lang.NoClassDefFoundError: com/mysema/query/types/Predicate 
at java.lang.Class.getDeclaredConstructors0(Native Method) 
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2413) 
at java.lang.Class.getDeclaredConstructors(Class.java:1855) 
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:227) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:930) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:903) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485) 
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) 
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) 
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) 
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) 
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) 
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:844) 
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:786) 
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:703) 
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:474) 
... 25 more 

有什麼不對?

我的倉庫是:

public interface IDomainRepository extends MongoRepository<Domain, String>{ 
} 

,當我給它添加QueryDslPredicateExecutor喜歡:

public interface IDomainRepository extends MongoRepository<Domain, String>, 
    QueryDslPredicateExecutor<Domain>{ 
} 

它的錯誤 - > NoClassDefFoundError->謂詞。

TNX

+0

有關此問題的任何更新? – 2013-04-23 13:35:43

+0

noooo,也許在下次嘗試... – prilia 2013-04-23 14:21:26

回答

1

Querydsl依賴不是傳遞在這裏。我建議從querydsl-mongodb中刪除optional = true。

Querydsl版本似乎沒問題,但很舊。

+0

我改變了Querydsl版本到3.1.0,但它仍然是一樣的錯誤。 – prilia 2013-04-09 13:06:12

+0

如果您不升級其他依賴項,Querydsl 3.1.0將不兼容,您是否刪除了可選標誌? – 2013-04-09 13:44:52

+0

是的,我刪除它,但仍然是相同的錯誤,你能告訴我什麼是新的和兼容的版本? TNX。 – prilia 2013-04-09 13:47:22