我正在尝试配置Jersey和Spring。我得到的错误如下:
从类路径资源解析XML文档时出现意外异常[applicationCo ntext.xml];嵌套异常是org.springframework.beans.FatalBeanException:无效的NamespaceHandler类[org.spring namespace.data.jpa.repository.config.JpaRepositoryNameSpaceHandler]用于名称空间[http://www.springframework.org/schema / data / jpa]:处理程序类文件或依赖类的问题;嵌套异常是java.lang.NoClassDefFoundError:org / springframework的/ AOP /框架/ AbstractAdvisingBeanPostProcessor
因为以下依赖
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-spring</artifactId>
<version>1.8</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</exclusion>
</exclusions>
</dependency>
我的pom还有以下spring依赖项:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
<!-- Spring Data -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>${spring-data.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency>
spring.verion = 3.2.0.RELEASE
spring-data.version = 1.2.1.RELEASE
如果我删除了jersey-spring工件,那么我的单元测试存储库字段没有任何异常。但是,当我启动我的服务器时,jetty抱怨它无法找到:
“2013-05-03 00:10:43.885:警告:oejs.Holder: java.lang.ClassNotFoundException:com.sun.jersey.spi.spring.container.servlet.SpringServlet 在org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50) 在org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244) 在org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230) 在org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:424) 在org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:377)“
jersey-spring依赖性是否与我的弹簧版本兼容?
答案 0 :(得分:0)
Jersey有一个旧版本的Spring AOP,所以我排除了依赖,问题得到了解决。