TomCat:在类路径资源

时间:2017-06-12 12:58:21

标签: java spring tomcat

我必须处理现有项目,但是我得到一个AbstractMethodError,试图将Spring部署到TomCat 8.5.14服务器中。

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerAdapter' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]: Factory method 'requestMappingHandlerAdapter' threw exception; nested exception is java.lang.AbstractMethodError: org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter$$EnhancerBySpringCGLIB$$ce4c0b3f.extendMessageConverters(Ljava/util/List;)V
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:598) ~[spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1155) ~[spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1049) ~[spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527) ~[spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:484) ~[spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302) ~[spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298) ~[spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) ~[spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:751) ~[spring-beans-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:865) ~[spring-context-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541) ~[spring-context-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:122) ~[spring-boot-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:795) ~[spring-boot-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:338) ~[spring-boot-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT]
at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:152) [spring-boot-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT]
at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:132) [spring-boot-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT]
at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:86) [spring-boot-2.0.0.BUILD-SNAPSHOT.jar:2.0.0.BUILD-SNAPSHOT]
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:171) [spring-web-5.0.0.BUILD-SNAPSHOT.jar:5.0.0.BUILD-SNAPSHOT]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5196) [catalina.jar:8.5.14]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:8.5.14]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752) [catalina.jar:8.5.14]
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728) [catalina.jar:8.5.14]
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734) [catalina.jar:8.5.14]
at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1702) [catalina.jar:8.5.14]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300) [tomcat-coyote.jar:8.5.14]
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) [na:1.8.0_121]
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) [na:1.8.0_121]
at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:482) [catalina.jar:8.5.14]
at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:431) [catalina.jar:8.5.14]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300) [tomcat-coyote.jar:8.5.14]
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) [na:1.8.0_121]
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) [na:1.8.0_121]
at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468) [na:1.8.0_121]
at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76) [na:1.8.0_121]
at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309) [na:1.8.0_121]
at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1401) [na:1.8.0_121]
at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829) [na:1.8.0_121]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:346) [na:1.8.0_121]
at sun.rmi.transport.Transport$1.run(Transport.java:200) [na:1.8.0_121]
at sun.rmi.transport.Transport$1.run(Transport.java:197) [na:1.8.0_121]
at java.security.AccessController.doPrivileged(Native Method) [na:1.8.0_121]
at sun.rmi.transport.Transport.serviceCall(Transport.java:196) [na:1.8.0_121]
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568) [na:1.8.0_121]
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826) [na:1.8.0_121]
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683) [na:1.8.0_121]
at java.security.AccessController.doPrivileged(Native Method) [na:1.8.0_121]
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682) [na:1.8.0_121]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_121]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0_121]
at java.lang.Thread.run(Thread.java:745) ~[na:1.8.0_121]

这是我的依赖树:

[INFO] Scanning for projects...                                                                            
[INFO]                                                                                                     
[INFO] ------------------------------------------------------------------------                            
[INFO] Building obws 0.1.1                                                                                 
[INFO] ------------------------------------------------------------------------                            
[INFO]                                                                                                     
[INFO] --- maven-dependency-plugin:2.10:tree (default-cli) @ obws ---                                      
[INFO] com.obws:obws:war:0.1.1                                                                             
[INFO] +- org.springframework.boot:spring-boot-starter-data-rest:jar:2.0.0.BUILD-SNAPSHOT:compile          
[INFO] |  +- org.springframework.boot:spring-boot-starter:jar:2.0.0.BUILD-SNAPSHOT:compile                 
[INFO] |  |  +- org.springframework.boot:spring-boot:jar:2.0.0.BUILD-SNAPSHOT:compile                      
[INFO] |  |  +- org.springframework.boot:spring-boot-autoconfigure:jar:2.0.0.BUILD-SNAPSHOT:compile        
[INFO] |  |  +- org.springframework.boot:spring-boot-starter-logging:jar:2.0.0.BUILD-SNAPSHOT:compile      
[INFO] |  |  |  +- ch.qos.logback:logback-classic:jar:1.2.3:compile                                        
[INFO] |  |  |  |  \- ch.qos.logback:logback-core:jar:1.2.3:compile                                        
[INFO] |  |  |  +- org.slf4j:jul-to-slf4j:jar:1.7.25:compile                                               
[INFO] |  |  |  \- org.slf4j:log4j-over-slf4j:jar:1.7.25:compile                                           
[INFO] |  |  \- org.yaml:snakeyaml:jar:1.18:runtime                                                        
[INFO] |  +- org.springframework.boot:spring-boot-starter-json:jar:2.0.0.BUILD-SNAPSHOT:compile            
[INFO] |  |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.0.pr3:compile                          
[INFO] |  |  |  \- com.fasterxml.jackson.core:jackson-core:jar:2.9.0.pr3:compile                           
[INFO] |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.9.0.pr3:compile                 
[INFO] |  |  \- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.9.0.pr3:compile               
[INFO] |  \- org.springframework.data:spring-data-rest-webmvc:jar:3.0.0.BUILD-SNAPSHOT:compile             
[INFO] |     +- org.springframework.data:spring-data-rest-core:jar:3.0.0.BUILD-SNAPSHOT:compile            
[INFO] |     |  +- org.springframework:spring-tx:jar:5.0.0.BUILD-SNAPSHOT:compile                          
[INFO] |     |  +- org.springframework.hateoas:spring-hateoas:jar:0.23.0.RELEASE:compile                   
[INFO] |     |  +- org.springframework.data:spring-data-commons:jar:2.0.0.BUILD-SNAPSHOT:compile           
[INFO] |     |  +- org.springframework.plugin:spring-plugin-core:jar:1.2.0.RELEASE:compile                 
[INFO] |     |  \- org.atteo:evo-inflector:jar:1.2.2:compile                                               
[INFO] |     \- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0.pr3:compile                       
[INFO] +- org.springframework.data:spring-data-rest-hal-browser:jar:3.0.0.BUILD-SNAPSHOT:compile           
[INFO] |  \- org.slf4j:slf4j-api:jar:1.7.25:compile                                                        
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.0.0.BUILD-SNAPSHOT:compile                
[INFO] |  +- org.hibernate:hibernate-validator:jar:5.4.1.Final:compile                                     
[INFO] |  |  +- javax.validation:validation-api:jar:1.1.0.Final:compile                                    
[INFO] |  |  +- org.jboss.logging:jboss-logging:jar:3.3.1.Final:compile                                    
[INFO] |  |  \- com.fasterxml:classmate:jar:1.3.3:compile                                                  
[INFO] |  +- org.springframework:spring-web:jar:5.0.0.BUILD-SNAPSHOT:compile                               
[INFO] |  |  +- org.springframework:spring-aop:jar:5.0.0.BUILD-SNAPSHOT:compile                            
[INFO] |  |  +- org.springframework:spring-beans:jar:5.0.0.BUILD-SNAPSHOT:compile                          
[INFO] |  |  \- org.springframework:spring-context:jar:5.0.0.BUILD-SNAPSHOT:compile                        
[INFO] |  \- org.springframework:spring-webmvc:jar:5.0.0.BUILD-SNAPSHOT:compile                            
[INFO] |     \- org.springframework:spring-expression:jar:5.0.0.BUILD-SNAPSHOT:compile                     
[INFO] +- org.springframework.boot:spring-boot-starter-web-services:jar:2.0.0.BUILD-SNAPSHOT:compile       
[INFO] |  +- org.springframework:spring-oxm:jar:5.0.0.BUILD-SNAPSHOT:compile                               
[INFO] |  \- org.springframework.ws:spring-ws-core:jar:2.4.0.RELEASE:compile                               
[INFO] |     \- org.springframework.ws:spring-xml:jar:2.4.0.RELEASE:compile                                
[INFO] +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.0.0.BUILD-SNAPSHOT:provided            
[INFO] |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.15:provided                                 
[INFO] |  +- org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.15:provided                                   
[INFO] |  \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.15:provided                            
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.0.0.BUILD-SNAPSHOT:test                  
[INFO] |  +- org.springframework.boot:spring-boot-test:jar:2.0.0.BUILD-SNAPSHOT:test                       
[INFO] |  +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.0.0.BUILD-SNAPSHOT:test         
[INFO] |  +- com.jayway.jsonpath:json-path:jar:2.2.0:test                                                  
[INFO] |  |  \- net.minidev:json-smart:jar:2.2.1:test                                                      
[INFO] |  |     \- net.minidev:accessors-smart:jar:1.1:test                                                
[INFO] |  |        \- org.ow2.asm:asm:jar:5.0.3:test                                                       
[INFO] |  +- junit:junit:jar:4.12:test                                                                     
[INFO] |  +- org.assertj:assertj-core:jar:3.8.0:test                                                       
[INFO] |  +- org.mockito:mockito-core:jar:2.8.9:test                                                       
[INFO] |  |  +- net.bytebuddy:byte-buddy:jar:1.6.14:test                                                   
[INFO] |  |  +- net.bytebuddy:byte-buddy-agent:jar:1.6.14:test                                             
[INFO] |  |  \- org.objenesis:objenesis:jar:2.5:test                                                       
[INFO] |  +- org.hamcrest:hamcrest-core:jar:1.3:test                                                       
[INFO] |  +- org.hamcrest:hamcrest-library:jar:1.3:test                                                    
[INFO] |  +- org.skyscreamer:jsonassert:jar:1.5.0:test                                                     
[INFO] |  |  \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test                      
[INFO] |  +- org.springframework:spring-core:jar:5.0.0.BUILD-SNAPSHOT:compile                              
[INFO] |  |  \- org.springframework:spring-jcl:jar:5.0.0.BUILD-SNAPSHOT:compile                            
[INFO] |  \- org.springframework:spring-test:jar:5.0.0.BUILD-SNAPSHOT:test                                 
[INFO] \- org.springframework.restdocs:spring-restdocs-mockmvc:jar:1.2.1.RELEASE:test                      
[INFO]    +- javax.servlet:javax.servlet-api:jar:3.1.0:test                                                
[INFO]    \- org.springframework.restdocs:spring-restdocs-core:jar:1.2.1.RELEASE:test                      
[INFO] ------------------------------------------------------------------------                            
[INFO] BUILD SUCCESS                                                                                       
[INFO] ------------------------------------------------------------------------                            
[INFO] Total time: 4.388 s                                                                                 
[INFO] Finished at: 2017-06-12T11:52:19+02:00                                                              
[INFO] Final Memory: 17M/42M                                                                               
[INFO] ------------------------------------------------------------------------                            

是依赖性错误吗?我该如何解决?

任何帮助都非常宝贵

更新

源代码:

ServletInitializer

package com.obws;

import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

public class ServletInitializer extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(ObwsApplication.class);
    }

}

ObwsApplication

package com.obws;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class ObwsApplication {

    public static void main(String[] args) {
        SpringApplication.run(ObwsApplication.class, args);
    }
}

RequestController

package com.obws;

import org.springframework.web.bind.annotation.*;

@RestController
public class RequestController {
    @RequestMapping(method = RequestMethod.GET, value = "/process/{level}")
    public @ResponseBody LibResponse process(@RequestParam(value = "path", defaultValue = "none") String path, @PathVariable("level") String level) {
        Request request = new Request(path, level);
        request.go();
        LibResponse libResponse = new LibResponse();
        libResponse.setBirds(request.getResult());
        return libResponse;

    }

    @RequestMapping("/greeting")
    public boolean greeting(@RequestParam(value="name", defaultValue="World") String name) {
        return true;
    }
}

其他类可能不会影响服务器

1 个答案:

答案 0 :(得分:0)

有同样的问题.. 我把这个添加到我的POM中它起作用了

<dependency>
    <groupId>com.jayway.jsonpath</groupId>
    <artifactId>json-path</artifactId>
    <version>2.2.0</version>
    <scope>test</scope>
</dependency>