我是新来的春天,基本上到Java超越了语言本身...最小的控制台应用程序,等等。我想在这里得到了Spring网站实例(https://spring.io/guides/gs/serving-web -content /)正常运行,而我尝试坚持使用示例中使用的spring boot部件,而不是通过构建和创建自己的servlet类,等等。在OS X Yosemite上使用Netbeans 8。
在此过程中,我已经能够解决许多问题,但是现在我陷入了这个错误。让我知道更多堆栈是否有用,我的pom在错误下方。任何方向都值得赞赏:
- -堆栈跟踪 - -
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jacksonObjectMapperBuilder' defined in class path resource [org/springframework/boot/autoconfigure/jackson/JacksonAutoConfiguration$JacksonObjectMapperBuilderConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.http.converter.json.Jackson2ObjectMapperBuilder]: Factory method 'jacksonObjectMapperBuilder' threw exception; nested exception is java.lang.NoSuchMethodError: org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.modulesToInstall([Lcom/fasterxml/jackson/databind/Module;)Lorg/springframework/http/converter/json/Jackson2ObjectMapperBuilder; at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1119)
---结束堆栈跟踪摘录---
-我的POM--
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework</groupId>
<artifactId>gs-serving-web-content</artifactId>
<version>0.1.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.5.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.1.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<!--version>1.3.0.BUILD-SNAPSHOT</version-->
</dependency>
</dependencies>
<properties>
<java.version>1.7</java.version>
<org.springframework.version>4.0.5.RELEASE</org.springframework.version>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<thymeleaf.version>2.1.4.RELEASE</thymeleaf.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-milestone</id>
<url>https://repo.spring.io/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-milestone</id>
<url>https://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
</project>
从pom来看,您正在混合至少3种不同的弹簧版本(4.2.0、4.1.4和4.0.5,甚至可能是弹簧靴中的4.1.6)。
要解决此问题,请删除所有其他org.springframework
依赖项,这些依赖项已通过spring-boot-starter-web
依赖项引入。
您的属性也会影响几件事,请删除所有这些java.version
属性,但除去该属性(如果确实需要,请离开thymeleaf属性)。
这些更改导致了一组经过测试的库,这些库将为您提供单个spring版本。
如果要更改春季版本,请在<properties>
名为的元素中添加一个属性,<spring.version>
然后指定要使用的特定春季版本。
<properties>
<spring.version>4.1.7.RELEASE</spring.version>
</properties>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句