我正在尝试配置 Jersey 和 Spring。我得到的错误如下:
从类路径资源 [applicationContext.xml] 解析 XML 文档时出现意外异常;嵌套异常是 org.springframework.beans.FatalBeanException: Invalid NamespaceHandler class [org.spring framework.data.jpa.repository.config.JpaRepositoryNameSpaceHandler] for namespace [ http://www.springframework.org/schema /data/jpa]:处理程序类文件或依赖类的问题;嵌套异常是 java.lang.NoClassDefFoundError: org/springframework/aop/framework/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 工件,那么我对存储库字段的单元测试将毫无例外地通过。但是,当我启动我的服务器码头时抱怨它找不到:
“2013-05-03 00:10:43.885:WARN:oejs.Holder: java.lang.ClassNotFoundException: com.sun.jersey.spi.spring.container.servlet.SpringServlet at 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 依赖项是否与我的 spring 版本兼容?