我已尽我所能修复此错误,在我的 pom 文件中添加了一些排除项,但仍然无法弄清楚为什么会出现此错误。
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.demo.project</groupId>
<artifactId>demoApi</artifactId>
<version>4.3.0.BUILD-SNAPSHOT</version>
<name>demoApi</name>
<description>HTTP REST WebService</description>
<properties>
<spring.version>4.2.5.RELEASE</spring.version>
<spring.integration.version>4.2.5.RELEASE</spring.integration.version>
<spring.security.version>4.0.4.RELEASE</spring.security.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>${spring.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-core</artifactId>
<version>${spring.integration.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-http</artifactId>
<version>${spring.integration.version}</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>org.springframework</artifactId>
<groupId>spring-webmvc</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jasypt</groupId>
<artifactId>jasypt</artifactId>
<version>1.7</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>${spring.security.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>${spring.security.version}</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>org.springframework</artifactId>
<groupId>spring-webmvc</groupId>
</exclusion>
<exclusion>
<artifactId>org.springframework</artifactId>
<groupId>spring-web</groupId>
</exclusion>
<exclusion>
<artifactId>org.springframework</artifactId>
<groupId>spring-beans</groupId>
</exclusion>
<exclusion>
<artifactId>org.springframework</artifactId>
<groupId>spring-core</groupId>
</exclusion>
<exclusion>
<artifactId>org.springframework</artifactId>
<groupId>spring-context</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- <dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.3.2</version>
<scope>compile</scope>
</dependency> -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.9.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>18.0</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
</dependencies>
<packaging>war</packaging>
<build>
<finalName>demoApi</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
我收到此错误的代码
package org.springframework.integration.samples.rest.json.view;
import java.util.Map;
import org.springframework.web.servlet.view.json.MappingJackson2JsonView;
/**
* ExtendedMappingJacksonJsonView.java: This class extends the Spring's MappingJacksonJsonView
* <p>
* Note: The source code for this class is taken from the forum posted by AhungerArtist
* at http://forum.springsource.org/archive/index.php/t-84006.html
* <p>
* @author Vigil Bose
* @author Gary Russell
*/
public class ExtendedMappingJacksonJsonView extends MappingJackson2JsonView {
@SuppressWarnings({"rawtypes" })
@Override
protected Object filterModel(Map<String, Object> model){
Object result = super.filterModel(model);
if (!(result instanceof Map)){
return result;
}
Map map = (Map) result;
if (map.size() == 1){
return map.values().toArray()[0];
}
return map;
}
}
编辑:依赖树输出
[INFO]com.demo.project:demoApi:war:4.3.0.BUILD-SNAPSHOT
[INFO] +- org.springframework:spring-oxm:jar:4.2.5.RELEASE:compile
[INFO] +- junit:junit:jar:4.11:test
[INFO] +- org.springframework:spring-test:jar:4.2.5.RELEASE:test
[INFO] +- org.springframework.integration:spring-integration-core:jar:4.2.5.RELE
ASE:compile
[INFO] +- org.springframework.integration:spring-integration-http:jar:4.2.5.RELE
ASE:compile
[INFO] +- org.springframework:spring-aop:jar:4.2.5.RELEASE:compile
[INFO] +- org.springframework:spring-web:jar:4.2.5.RELEASE:compile
[INFO] +- org.springframework:spring-context:jar:4.2.5.RELEASE:compile
[INFO] +- org.springframework:spring-webmvc:jar:4.2.5.RELEASE:compile
[INFO] +- org.hamcrest:hamcrest-all:jar:1.3:test
[INFO] +- org.jasypt:jasypt:jar:1.7:compile
[INFO] +- org.springframework:spring-tx:jar:4.2.5.RELEASE:compile
[INFO] +- log4j:log4j:jar:1.2.17:compile
[INFO] +- org.springframework.security:spring-security-config:jar:4.0.4.RELEASE:
compile
[INFO] +- org.springframework.security:spring-security-web:jar:4.0.4.RELEASE:com
pile
[INFO] +- org.mockito:mockito-core:jar:1.9.5:test
[INFO] +- org.springframework:spring-jdbc:jar:4.2.5.RELEASE:compile
[INFO] +- javax.servlet:servlet-api:jar:2.5:compile
[INFO] +- com.oracle:ojdbc6:jar:11.2.0:compile
[INFO] +- com.google.guava:guava:jar:18.0:compile
[INFO] +- javax.ws.rs:javax.ws.rs-api:jar:2.0.1:compile
[INFO] \- javax.inject:javax.inject:jar:1:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.143 s
[INFO] Finished at: 2016-05-04T13:44:59+05:30
[INFO] Final Memory: 14M/197M
[INFO] ------------------------------------------------------------------------
编辑2:忘了提一件重要的事情。我们没有使用 Maven 仓库,而是我们自己的私有仓库。我已经下载了所有 jar 并导入到我们的仓库中。我反复跑来mvn clean -U install
查看是否有任何错误并修复它。
感谢所有回答的人。由于我必须尽快完成工作,所以我决定使用 Spring WS 而不是 JAX-RS!我们已经有工作的 Spring REST WS,因此决定进一步使用它。如果我的组织放弃使用私人回购的想法,我永远不会陷入这种混乱。