本文介绍了将Spring Boot RESTful Web服务部署到Tomcat时仍然缺少Web.xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我试图将使用Spring Boot构建的RESTful Web Service部署到Tomcat实例中,但收效甚微。我的软件配置如下:我的电脑是一个运行 OS X Yosemite 10.10.3 ,并带有 Oracle的JDK 8 1.8.0_45 , Gradle 2.4 和 Apache Tomcat 7.0.47 。我使用 IntelliJ IDEA 14.1.4 作为开发平台。 我是从 guide ,我得到一个jar,它启动一个按预期工作的嵌入式容器。然后,我将关于将Spring Boot JAR应用程序转换为WAR 的文档关联到其他指南。我遵循第59.4节打包可执行文件和WAR文件中的指示信息,然后是第74.1节创建可部署的WAR文件 code>。根据这个网站的其他一些成员面临同样问题的帖子( here ,此处,这里和这里,只是仅举几例),我应该现在可以创建一个WAR并将其部署到我的Tomcat上。不幸的是,情况并非如此。 该项目包含以下3个Java文件: Application.java , Greeting.java 和 GreetingController.java 。第一个如下所示: package hello; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.context.web.SpringBootServletInitializer; import org.springframework.context.annotation.Configuration; @Configuration @EnableAutoConfiguration @SpringBootApplication public class Application扩展SpringBootServletInitializer { public static void main(String [] args) { SpringApplication.run(Application.class,args); } @Override 保护SpringApplicationBuilder配置(SpringApplicationBuilder应用程序){返回application.sources(Application.class); } } 第二个文件包含以下内容: package hello; public class Greeting { private final long id; private final String内容; 公共问候(长ID,字符串内容){ this.id = id; this.content = content; } public long getId(){ return id; } public String getContent(){ return content; } } 最后,后一个文件是: package hello; import java.util.concurrent.atomic.AtomicLong; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @RestController public class GreetingController { private static final String template =Hello,%s!; private final AtomicLong counter = new AtomicLong(); @RequestMapping(/ hello)公共问候语(@RequestParam(value =name,defaultValue =World)字符串名称){返回新问候语(counter.incrementAndGet(),String.format(template,name)); $ / code $ / pre 该项目还包含以下build.gradle文件: buildscript {存储库{ mavenCentral()} 依赖关系{ classpath(org.springframework.boot:spring-boot-gradle-plugin:1.2.4.RELEASE)} } apply plugin:' war' apply plugin:'java' apply plugin:'idea' apply plugin:'spring-boot' sourceCompatibility = 1.8 targetCompatibility = 1.8 war { baseName ='rest' // version ='0.1.0'} repositories { mavenLocal() mavenCentral()} 配置{ providedRuntime } 依赖关系{ compile(org.springframework.boot:spring-boot-starter-web) providedRuntime(org.springframework.boot:spring-boot-starter-tomcat) testCompile(junit :junit)} 现在,如果我运行gradle war任务,则会生成一个约8 MB的WAR文件。我可以成功地将它部署到我的本地Tomcat,但是当我将浏览器指向 http:// localhost :8080 / rest / hello?name = World 我得到一个空白页面,而不是带有预期JSON的页面。如果我运行gradle build或gradle bootRepackage任务,我同时获得JAR和WAR以及它们的原始版本。我提到这些命令是因为我没有在任何地方看到它们,它们可能对我们有用。原始版本的尺寸都是8 Mb左右,而JAR和12 Mb的WAR都是。如果我部署两个WAR,则不会收到错误消息,但在浏览器中也不会显示任何结果。这里有人建议web.xml可能会丢失,实际上没有WAR实际包含这样的文件。我之所以这样说是因为我的Tomcat不是最近的,出于某种原因,我认为Spring Boot必须从上面的代码和注释中自动创建 web.xml 。 正如@dunni在评论中所建议的,这里是我的Tomcat日志文件。首先, catalina.log : giu 24,2015 10 :35:01 AM org.apache.catalina.startup.HostConfig deployWAR INFO:部署Web应用程序存档/usr/local/apache-tomcat-7.0.47/webapps/rest.war 然后 localhost.log : giu 24,2015 10:35:02 AM org.apache.catalina.core.ApplicationContext log INFO:在类路径中检测到Spring WebApplicationInitializers:[org.springframework .boot.autoconfigure.jersey.JerseyAutoConfiguration @ 4dfaba52] 最后经理。日志: giu 24,2015 10:34:43 AM org.apache.catalina.core .ApplicationContext log INFO:HTMLManager:list:列出虚拟主机'localhost'的上下文 giu 24,2015 10:34:44 AM org.apache.catalina.core.ApplicationContext log INFO :HTMLManager:list:列出虚拟主机'localhost'的上下文 giu 24,2015 10:35:02 AM org.apac he.catalina.core.ApplicationContext log INFO:HTMLManager:list:列出虚拟主机'localhost'的上下文 以上内容是我在部署WAR后获得的内容。如果我随后尝试连接到 http:// localhost:8080 / , http:// localhost:8080 / rest / , http:// localhost:8080 / rest / hello 或 http ://本地主机:8080 / REST /你好名=世界。 发生了什么事?我错过了什么?你能解释我有什么问题吗?我该怎么做才能在Tomcat上成功部署这个玩具服务?非常感谢。 由于上述日志并不真正有帮助,我尝试重新启动Tomcat守护进程,更有意义的东西。现在我有以下文件: catalina.log , catalina.out , host-manager .log (空), launchd.stderr (空), launchd.stdout , localhost_access_log.txt (空), localhost.log 和 manager.log (空)。 catalina.log 和 catalina.out 现在包含以下内容: giu 24,2015 11:11:49 AM org.apache.catalina.core.AprLifecycleListener init INFO:基于APR的Apache Tomcat本机库,它允许在生产环境在java.library.path上找不到:/ Users / stefano / Library / Java / Extensions:/ Library / Java / Extensions:/ Network / Library / Java / Extensions:/ System / Library / Java / Extensions:/ usr / lib中/ JAVA :. giu 24,2015 11:11:49 AM org.apache.coyote.AbstractProtocol init INFO:初始化ProtocolHandler [http-bio-8080] giu 24,2015 11:11 :49 AM org.apache.coyote.AbstractProtocol init INFO:初始化ProtocolHandler [ajp-bio-8009] giu 24,2015 11:11:49 AM org.apache.catalina.startup。 Catalina加载 INFO:初始化处理在666 ms giu 24,2015 11:11:49 AM org.apache.catalina.core.StandardService startInternal INFO:启动服务Catalina giu 24,2015 11:11:49 AM org.apache.catalina.core.StandardEngine startInternal INFO:启动Servlet引擎:Apache Tomcat / 7.0.47 giu 24,2015 11:11:49 AM org.apache.catalina.startup.HostConfig deployWAR 信息:部署Web应用程序存档/usr/local/apache-tomcat-7.0.47/webapps/Plakko.war giu 24,2015 11:11: 51 AM org.apache.catalina.util.SessionIdGenerator createSecureRandom INFO:使用[SHA1PRNG]创建会话ID生成的SecureRandom实例[57 4]毫秒。 giu 24,2015 11:11:51 AM org.apache.catalina.startup.HostConfig deployWAR 信息:部署Web应用程序存档/usr/local/apache-tomcat-7.0.47/webapps/rest .war giu 24,2015 11:11:52 AM org.apache.catalina.startup.HostConfig deployDirectory 信息:部署Web应用程序目录/usr/local/apache-tomcat-7.0.47/webapps / docs giu 24,2015 11:11:52 AM org.apache.catalina.startup.HostConfig deployDirectory 信息:部署Web应用程序目录/usr/local/apache-tomcat-7.0.47/webapps / host-manager giu 24,2015 11:11:53 AM org.apache.catalina.startup.HostConfig deployDirectory 信息:部署Web应用程序目录/usr/local/apache-tomcat-7.0.47 / webapps / manager giu 24,2015 11:11:53 AM org.apache.catalina.startup.HostConfig deployDirectory 信息:部署Web应用程序目录/usr/local/apache-tomcat-7.0.47 / webapps / ROOT giu 24,2015 11:11:53 AM org.apache.coyote.AbstractProtocol start INFO:Starting ProtocolHandler [ http-bio-8080] giu 24,2015 11:11:53 AM org.apache.coyote.AbstractProtocol start INFO:Starting ProtocolHandler [ajp-bio-8009] giu 24,2015 11:11:53 AM org.apache.catalina.startup.Catalina start INFO:服务器启动3349 ms launchd.stdout 包含: Wed Jun 24 11:11:48 CEST 2015 启动Tomcat 等待89105 和 localhost.log 包含: giu 24 ,2015 11:11:52 AM org.apache.catalina.core.ApplicationContext log INFO:在类路径中检测到Spring WebApplicationInitializers:[org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration@2d5eb959] 如果我尝试使用Web服务, localhost_access_log.txt 是更新为: 217.20.22.194 - - [24 / Jun / 2015:11:23:16 +0200]GET / HTTP / 1.1200 11444 217.20.22.194 - - [2 4 / Jun / 2015:11:23:19 +0200]GET / rest / HTTP / 1.1404 5 217.20.22.194 - - [24 / Jun / 2015:11:23:19 +0200] GET / rest / hello HTTP / 1.1404 5 217.20.22.194 - - [24 / Jun / 2015:11:23:20 +0200]GET / rest / hello?name = World HTTP / 1.1404 5 由于我感觉这些日志是不是很有帮助,我尝试关闭并启动Tomcat。在这种情况下,我在 catalina.log 和 catalina.out 中找到了一些有趣的内容。前者: giu 24,2015 11:36:56 AM org.apache.catalina.startup.HostConfig deployWAR INFO:部署Web应用程序存档/usr/local/apache-tomcat-7.0.47/webapps/rest.war giu 24,2015 11:36:59 AM org.apache.catalina.core.ContainerBase addChildInternal SEVERE:ContainerBase.addChild:start: org.apache.catalina.LifecycleException:无法启动组件[StandardEngine [Catalina] .StandardHost [localhost] .StandardContext [/ rest]] at org .apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) at org.apache.catalina .core.ContainerBase.addChild(ContainerBase.java:877) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633) at org.apache.catalina.startup.HostConfig .deployWAR(HostConfig.java:983) at org.apache.catalina.startup.HostConfig $ DeployWar.run(HostConfig.java:1660)在java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:471)$ b $在java.util.concurrent.FutureTask.run(FutureTask.java:262)在java.util.concurrent .ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)$ java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:615)$ b $在java.lang.Thread.run(Thread.java :724)。通过引起:java.lang.NoSuchMethodError:java.lang.reflect.Parameter.isNamePresent()Z 。在org.springframework.core.StandardReflectionParameterNameDiscoverer.getParameterNames(StandardReflectionParameterNameDiscoverer.java:56)。在org.springframework.core.PrioritizedParameterNameDiscoverer.getParameterNames(PrioritizedParameterNameDiscoverer.java:65)在org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:182)。在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireC apableBeanFactory.java:1139)美元,org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1042 B $ B)在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean( AbstractAutowireCapableBeanFactory.java:504) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) at org.springframework.beans.factory.support.AbstractBeanFactory $ 1.getObject (AbstractBeanFactory.java:303) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (AbstractBeanFactory.java:299) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) at org.springframework.boot.autoconfigu re.condition.BeanTypeRegistry $ OptimizedBeanTypeRegistry.getFromFactory(BeanTypeRegistry.java:320)处org.springframework org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.get(BeanTypeRegistry.java:162)。 boot.autoconfigure.condition.OnBeanCondition.collectBeanNamesForType(OnBeanCondition.java:158)$ or $。 org.springframework.boot.autoconfigure.condition.OnBeanCondition.getBeanNamesForType(OnBeanCondition.java:147) at org.springframework。 boot.autoconfigure.condition.OnBeanCondition.getMatchingBeans(OnBeanCondition.java:119)处org.springframework org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchOutcome(OnBeanCondition.java:94)。 boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:45)处org.springframework.context org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:102)。 annotation.ConfigurationClassBeanDefi nitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:190)在org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:148)在org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions( 位于org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java: 239) at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:254) at org.springframework.context.support.PostProcessorRegistrationDelegate.in vokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:94) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:606) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext。 at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686) at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)在org.springframework.boot.context.web.SpringBootServletInitializer.run(SpringBootServletInitializer.java:117)在org.springframework.boot.context.web.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:108)在org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletInitializer.java:68) tContainerInitializer.java:175) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5423) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java: 150) ... 10 more giu 24,2015 11:36:59 AM org.apache.catalina.startup.HostConfig deployWAR SEVERE:部署Web应用程序归档时出错/usr/local/apache-tomcat-7.0.47/webapps/rest.war java.lang.IllegalStateException:ContainerBase.addChild:start:org.apache.catalina.LifecycleException:无法启动组件[StandardEngine [Catalina ] .StandardHost [localhost] .StandardContext [/ rest]] at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:904) at org.apache.catalina.core.ContainerBase .addChild(ContainerBase.java:877) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig .java:983)在org.apache.catalina.star tup.HostConfig $ DeployWar.run(HostConfig.java:1660)维持在java.util.concurrent.FutureTask中java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:471) 。运行(FutureTask.java:262)在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java: 615)在java.lang.Thread.run(Thread.java:724) 后者 catalina.out : giu 24,2015 11: 36:56 AM org.apache.catalina.startup.HostConfig deployWAR INFO:部署Web应用程序存档/usr/local/apache-tomcat-7.0.47/webapps/rest.war 。 ____ _ _ _ _ _ / \\ / ___'_ __ _ _(_)_ _ _ _ _ _ \\\\\ (()\ ___ |'_ | '_ | |'_ \ / _` | \\\\ \\ / ___)| | _)| | | | | || (_ | |))))'| ____ | .__ | _ | | _ | _ | | _\__,| / / / / ========= | _ | ============== | ___ / = / _ / _ / _ / : :Spring Boot ::(v1.2.4.RELEASE) 2015-06-24 11:36:59.019信息89274 --- [ost-startStop-1] osboot.SpringApplication:启动应用程序带有PID 89274的Mac-mini-di-Stefano.local(/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/spring-boot-1.2.4.RELEASE.jar由stefano开始在/usr/local/apache-tomcat-7.0.47/bin) 2015年6月24日11:36:59.047 INFO 89274 --- [OST-startStop-1] scaAnnotationConfigApplicationContext:刷新org.springframework。 context.annotation.AnnotationConfigApplicationContext@34a13c2b:启动日期[Wed Jun 24 11:36:59 CEST 2015];上下文层次根 2015-06-24 11:36:59.648信息89274 --- [ost-startStop-1] .blClasspathLoggingApplicationListener:应用程序无法以类路径启动:[file:/ usr / local / apache -tomcat-7.0.47 / webapps / rest / WEB-INF / classes /,文件:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/aopalliance-1.0.jar,file :/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/classmate-1.0.0.jar,文件:/usr/local/apache-tomcat-7.0.47/webapps/rest /WEB-INF/lib/hibernate-validator-5.1.3.Final.jar,文件:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/jackson-annotations-2.4。 0.jar,文件:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/jackson-core-2.4.6.jar,文件:/ usr / local / apache-tomcat- 7.0.47 / webapps / rest / WEB-INF / lib / jackson-databind-2.4.6.jar,文件:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/jboss -logging-3.1.3.GA.jar,file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/jcl-over-slf4j-1.7.12.jar,file: /usr/local/apache-tomcat-7.0.47/webap ps / rest / WEB-INF / lib / jul-to-slf4j-1.7.12.jar,文件:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/log4j-over -slf4j-1.7.12.jar,文件:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/logback-classic-1.1.3.jar,文件:/ usr / local /apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/logback-core-1.1.3.jar,文件:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB- INF / lib目录/ SLF4J-API 1.7.12.jar,文件:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/snakeyaml-1.14.jar,文件:在/ usr / local / apache-tomcat-7.0.47 / webapps / rest / WEB-INF / lib / spring-aop-4.1.6.RELEASE.jar,文件:/usr/local/apache-tomcat-7.0.47/webapps/rest /WEB-INF/lib/spring-beans-4.1.6.RELEASE.jar,文件:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/spring-boot-1.2。 4.RELEASE.jar,文件:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/spring-boot-autocon figigure-1.2.4.RELEASE.jar,文件:/ usr / local / apache-tomcat-7.0.47 / webapps / rest / WEB-INF / lib / spring-boot-starter-1.2.4.RELEASE.jar,文件:/usr/local/apache-tomcat-7.0.47 /webapps/rest/WEB-INF/lib/spring-boot-starter-logging-1.2.4.RELEASE.jar,file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/ lib / spring-boot-starter-web-1.2.4.RELEASE.jar,文件:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/spring-context-4.1.6 .RELEASE.jar,文件:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/spring-core-4.1.6.RELEASE.jar,文件:/ usr / local / apache -tomcat-7.0.47 / webapps / rest / WEB-INF / lib / spring-expression-4.1.6.RELEASE.jar,文件:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB- INF / lib / spring-web-4.1.6.RELEASE.jar,文件:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/spring-webmvc-4.1.6.RELEASE .jar,文件:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/validation-api-1.1.0.Final.jar] 2015-06-24 11 :36:59.663 ERROR 89274 --- [OST-startStop-1] osboot.SpringApplication:应用启动失败 java.lang.NoSuchMethodError:java.lang.reflect.Parameter.isNamePresent()z 在org.springframework.cor e.StandardReflectionParameterNameDiscoverer.getParameterNames(StandardReflectionParameterNameDiscoverer.java:56) at org.springframework.core.PrioritizedParameterNameDiscoverer.getParameterNames(PrioritizedParameterNameDiscoverer.java:65) at org.springframework.beans.factory.support.ConstructorResolver。 autowireConstructor(ConstructorResolver.java:182) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1139) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory。在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)上在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory中。 createBean(AbstractAutowireCapableBeanFactory.java:476) at org.springframew ork.beans.factory.support.AbstractBeanFactory $ 1.getObject(AbstractBeanFactory.java:303) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org .springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)在org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)。在组织.springframework.boot.autoconfigure.condition.BeanTypeRegistry $ OptimizedBeanTypeRegistry.getFromFactory(BeanTypeRegistry.java:320) at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.get(BeanTypeRegistry.java:162)在org.springframework.boot.autoconfigure.condition.OnBeanCondition.collectBeanNamesForType(OnBeanCondition.java:158)在org.springframework.boot.autoconfigure.condition.OnBeanCondition.getBeanNamesForType(OnBeanCondition.java:147)在org.springframework.boot.autoconfi gure.condition.OnBeanCondition.getMatchingBeans(OnBeanCondition.java:119)处org.springframework.boot org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchOutcome(OnBeanCondition.java:94)。 autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:45) at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:102) at org.springframework.context.annotation。 ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:190)在org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:148)在org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions( ConfigurationClassBeanDefinitionReader.java:124)$ or $ 在org.springframework.context.annotation.ConfigurationClass PostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:318) at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:239) at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessor( PostProcessorRegistrationDelegate.java:254) at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:94) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java: at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:462) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686)在org.springframework.boot.SpringApplication.run(SpringApplicatio n.java:320)在org.springframework.boot.context.web.SpringBootServletInitializer.run(SpringBootServletInitializer.java:117)在org.springframework.boot.context.web.SpringBootServletInitializer.createRootApplicationContext( (SpringBootServletInitializer.java:108)在org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java: at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5423) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)$ b在org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) $ b在org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)。在组织.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)在org.apache.catalina.startu p.HostConfig.deployWAR(HostConfig.java:983) at org.apache.catalina.startup.HostConfig $ DeployWar.run(HostConfig.java:1660) at java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:471)在java.util.concurrent.FutureTask.run(FutureTask.java:262)在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java: 1145)在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:615)$ b $在java.lang.Thread.run(Thread.java:724) code> 通过查看这些日志,我感觉到Spring的自动神奇过程中发生了某些失败,但不幸的是,不知道该如何解决。任何帮助?解决方案你使用的是什么版本的java? gradle文件表明你打算使用java 8,但是这个错误表明你不是... java.lang.NoSuchMethodError :java.lang.reflect.Parameter.isNamePresent() 参数类直到java 8 才被引入。你的tomcat使用的是什么版本的Java? I am trying to deploy a RESTful Web Service built with Spring Boot into a Tomcat instance, with little success.My software configuration is as follows: my computer is a Mac running OS X Yosemite 10.10.3, with Oracle Java JDK 8 1.8.0_45, Gradle 2.4 and Apache Tomcat 7.0.47. I use IntelliJ IDEA 14.1.4 as development platform.I started by following this guide and I got a jar that initiates an embedded container which works as expected. Then I followed the document about converting a Spring Boot JAR Application to a WAR linked at the end of the other guide. I followed the instructions in Section 59.4 "Packaging executable jar and war files" and then those in the Section 74.1 "Create a deployable war file". According to the posts of a few other members of this site who were facing the same problem (here, here, here and here, just to name a few), I should be able now to create a create a WAR and deploy it on my Tomcat. Unfortunately, this is not the case.The project contains the following 3 Java files: Application.java, Greeting.java and GreetingController.java. The first is as follows:package hello;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.EnableAutoConfiguration;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.boot.builder.SpringApplicationBuilder;import org.springframework.boot.context.web.SpringBootServletInitializer;import org.springframework.context.annotation.Configuration;@Configuration@EnableAutoConfiguration@SpringBootApplicationpublic class Application extends SpringBootServletInitializer { public static void main(String[] args) { SpringApplication.run(Application.class, args); } @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(Application.class); }}The second file contains the following:package hello;public class Greeting { private final long id; private final String content; public Greeting(long id, String content) { this.id = id; this.content = content; } public long getId() { return id; } public String getContent() { return content; }}And, finally, the latter file is:package hello;import java.util.concurrent.atomic.AtomicLong;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestParam;import org.springframework.web.bind.annotation.RestController;@RestControllerpublic class GreetingController { private static final String template = "Hello, %s!"; private final AtomicLong counter = new AtomicLong(); @RequestMapping("/hello") public Greeting greeting(@RequestParam(value="name", defaultValue="World") String name) { return new Greeting(counter.incrementAndGet(), String.format(template, name)); }}The project also contains the following build.gradle file:buildscript { repositories { mavenCentral() } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.4.RELEASE") }}apply plugin: 'war'apply plugin: 'java'apply plugin: 'idea'apply plugin: 'spring-boot'sourceCompatibility = 1.8targetCompatibility = 1.8war { baseName = 'rest'// version = '0.1.0'}repositories { mavenLocal() mavenCentral()}configurations { providedRuntime}dependencies { compile("org.springframework.boot:spring-boot-starter-web") providedRuntime("org.springframework.boot:spring-boot-starter-tomcat") testCompile("junit:junit")}Now, if I run the task "gradle war", I generate a WAR file of about 8 Mb. I can successfully deploy it to my local Tomcat, but when I point my browser to http://localhost:8080/rest/hello?name=World I got a blank page rather than the page with the expected JSON. If I run the task "gradle build" or "gradle bootRepackage", I get both a JAR and a WAR and their original versions. I'm mentioning these commands because I haven't seen them anywhere and they might be useful to know. The original versions are both around 8 Mb in size, while the JAR and the WAR of 12 Mb. If I deploy both WARs, I get no error messages but, again, no results in the browser. Somebody here suggested that the web.xml could be missing, and in fact no WAR actually contained such a file. I am saying so because my Tomcat is not very recent and for some reason I thought Spring Boot had to automatically create a web.xml out of the code and annotations above.As suggested by @dunni in the comments, here are my Tomcat log files. First of all, catalina.log:giu 24, 2015 10:35:01 AM org.apache.catalina.startup.HostConfig deployWARINFO: Deploying web application archive /usr/local/apache-tomcat-7.0.47/webapps/rest.warThen localhost.log:giu 24, 2015 10:35:02 AM org.apache.catalina.core.ApplicationContext logINFO: Spring WebApplicationInitializers detected on classpath: [org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration@4dfaba52]And finally manager.log:giu 24, 2015 10:34:43 AM org.apache.catalina.core.ApplicationContext logINFO: HTMLManager: list: Listing contexts for virtual host 'localhost'giu 24, 2015 10:34:44 AM org.apache.catalina.core.ApplicationContext logINFO: HTMLManager: list: Listing contexts for virtual host 'localhost'giu 24, 2015 10:35:02 AM org.apache.catalina.core.ApplicationContext logINFO: HTMLManager: list: Listing contexts for virtual host 'localhost'The above content is what I get after deploy the WAR. Nothing changes if I subsequently try to connect to http://localhost:8080/, http://localhost:8080/rest/, http://localhost:8080/rest/hello or http://localhost:8080/rest/hello?name=World.What is going on? What am I missing? Can you please explain me what is the problem and what have I to do to successfully deploy this toy service on Tomcat? Many thanks in advance.Since the above logs were not really helpful, I tried to restart the Tomcat daemon and I got something more meaningful. Now I have the following files: catalina.log, catalina.out, host-manager.log (empty), launchd.stderr (empty), launchd.stdout, localhost_access_log.txt (empty), localhost.log and manager.log (empty). catalina.log and catalina.out now contains the following:giu 24, 2015 11:11:49 AM org.apache.catalina.core.AprLifecycleListener initINFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /Users/stefano/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.giu 24, 2015 11:11:49 AM org.apache.coyote.AbstractProtocol initINFO: Initializing ProtocolHandler ["http-bio-8080"]giu 24, 2015 11:11:49 AM org.apache.coyote.AbstractProtocol initINFO: Initializing ProtocolHandler ["ajp-bio-8009"]giu 24, 2015 11:11:49 AM org.apache.catalina.startup.Catalina loadINFO: Initialization processed in 666 msgiu 24, 2015 11:11:49 AM org.apache.catalina.core.StandardService startInternalINFO: Starting service Catalinagiu 24, 2015 11:11:49 AM org.apache.catalina.core.StandardEngine startInternalINFO: Starting Servlet Engine: Apache Tomcat/7.0.47giu 24, 2015 11:11:49 AM org.apache.catalina.startup.HostConfig deployWARINFO: Deploying web application archive /usr/local/apache-tomcat-7.0.47/webapps/Plakko.wargiu 24, 2015 11:11:51 AM org.apache.catalina.util.SessionIdGenerator createSecureRandomINFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [574] milliseconds.giu 24, 2015 11:11:51 AM org.apache.catalina.startup.HostConfig deployWARINFO: Deploying web application archive /usr/local/apache-tomcat-7.0.47/webapps/rest.wargiu 24, 2015 11:11:52 AM org.apache.catalina.startup.HostConfig deployDirectoryINFO: Deploying web application directory /usr/local/apache-tomcat-7.0.47/webapps/docsgiu 24, 2015 11:11:52 AM org.apache.catalina.startup.HostConfig deployDirectoryINFO: Deploying web application directory /usr/local/apache-tomcat-7.0.47/webapps/host-managergiu 24, 2015 11:11:53 AM org.apache.catalina.startup.HostConfig deployDirectoryINFO: Deploying web application directory /usr/local/apache-tomcat-7.0.47/webapps/managergiu 24, 2015 11:11:53 AM org.apache.catalina.startup.HostConfig deployDirectoryINFO: Deploying web application directory /usr/local/apache-tomcat-7.0.47/webapps/ROOTgiu 24, 2015 11:11:53 AM org.apache.coyote.AbstractProtocol startINFO: Starting ProtocolHandler ["http-bio-8080"]giu 24, 2015 11:11:53 AM org.apache.coyote.AbstractProtocol startINFO: Starting ProtocolHandler ["ajp-bio-8009"]giu 24, 2015 11:11:53 AM org.apache.catalina.startup.Catalina startINFO: Server startup in 3349 mslaunchd.stdout contains:Wed Jun 24 11:11:48 CEST 2015Starting TomcatWaiting for 89105And localhost.log contains:giu 24, 2015 11:11:52 AM org.apache.catalina.core.ApplicationContext logINFO: Spring WebApplicationInitializers detected on classpath: [org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration@2d5eb959]If I try to consume the Web Service, localhost_access_log.txt is updated with:217.20.22.194 - - [24/Jun/2015:11:23:16 +0200] "GET / HTTP/1.1" 200 11444217.20.22.194 - - [24/Jun/2015:11:23:19 +0200] "GET /rest/ HTTP/1.1" 404 5217.20.22.194 - - [24/Jun/2015:11:23:19 +0200] "GET /rest/hello HTTP/1.1" 404 5217.20.22.194 - - [24/Jun/2015:11:23:20 +0200] "GET /rest/hello?name=World HTTP/1.1" 404 5Since I have the feeling that these logs are not really helpful, I tried to shutdown and startup Tomcat. In this case I find something interesting in catalina.log and catalina.out. The former:giu 24, 2015 11:36:56 AM org.apache.catalina.startup.HostConfig deployWARINFO: Deploying web application archive /usr/local/apache-tomcat-7.0.47/webapps/rest.wargiu 24, 2015 11:36:59 AM org.apache.catalina.core.ContainerBase addChildInternalSEVERE: ContainerBase.addChild: start:org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/rest]] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:983) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1660) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:724)Caused by: java.lang.NoSuchMethodError: java.lang.reflect.Parameter.isNamePresent()Z at org.springframework.core.StandardReflectionParameterNameDiscoverer.getParameterNames(StandardReflectionParameterNameDiscoverer.java:56) at org.springframework.core.PrioritizedParameterNameDiscoverer.getParameterNames(PrioritizedParameterNameDiscoverer.java:65) at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:182) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1139) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1042) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry$OptimizedBeanTypeRegistry.getFromFactory(BeanTypeRegistry.java:320) at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.get(BeanTypeRegistry.java:162) at org.springframework.boot.autoconfigure.condition.OnBeanCondition.collectBeanNamesForType(OnBeanCondition.java:158) at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getBeanNamesForType(OnBeanCondition.java:147) at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchingBeans(OnBeanCondition.java:119) at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchOutcome(OnBeanCondition.java:94) at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:45) at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:102) at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:190) at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:148) at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:124) at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:318) at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:239) at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:254) at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:94) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:606) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:462) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686) at org.springframework.boot.SpringApplication.run(SpringApplication.java:320) at org.springframework.boot.context.web.SpringBootServletInitializer.run(SpringBootServletInitializer.java:117) at org.springframework.boot.context.web.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:108) at org.springframework.boot.context.web.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:68) at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:175) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5423) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ... 10 moregiu 24, 2015 11:36:59 AM org.apache.catalina.startup.HostConfig deployWARSEVERE: Error deploying web application archive /usr/local/apache-tomcat-7.0.47/webapps/rest.warjava.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/rest]] at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:904) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:983) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1660) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:724)And the latter catalina.out:giu 24, 2015 11:36:56 AM org.apache.catalina.startup.HostConfig deployWARINFO: Deploying web application archive /usr/local/apache-tomcat-7.0.47/webapps/rest.war . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v1.2.4.RELEASE)2015-06-24 11:36:59.019 INFO 89274 --- [ost-startStop-1] o.s.boot.SpringApplication : Starting application on Mac-mini-di-Stefano.local with PID 89274 (/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/spring-boot-1.2.4.RELEASE.jar started by stefano in /usr/local/apache-tomcat-7.0.47/bin)2015-06-24 11:36:59.047 INFO 89274 --- [ost-startStop-1] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@34a13c2b: startup date [Wed Jun 24 11:36:59 CEST 2015]; root of context hierarchy2015-06-24 11:36:59.648 INFO 89274 --- [ost-startStop-1] .b.l.ClasspathLoggingApplicationListener : Application failed to start with classpath: [file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/classes/, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/aopalliance-1.0.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/classmate-1.0.0.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/hibernate-validator-5.1.3.Final.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/jackson-annotations-2.4.0.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/jackson-core-2.4.6.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/jackson-databind-2.4.6.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/jboss-logging-3.1.3.GA.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/jcl-over-slf4j-1.7.12.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/jul-to-slf4j-1.7.12.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/log4j-over-slf4j-1.7.12.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/logback-classic-1.1.3.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/logback-core-1.1.3.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/slf4j-api-1.7.12.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/snakeyaml-1.14.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/spring-aop-4.1.6.RELEASE.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/spring-beans-4.1.6.RELEASE.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/spring-boot-1.2.4.RELEASE.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/spring-boot-autoconfigure-1.2.4.RELEASE.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/spring-boot-starter-1.2.4.RELEASE.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/spring-boot-starter-logging-1.2.4.RELEASE.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/spring-boot-starter-web-1.2.4.RELEASE.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/spring-context-4.1.6.RELEASE.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/spring-core-4.1.6.RELEASE.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/spring-expression-4.1.6.RELEASE.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/spring-web-4.1.6.RELEASE.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/spring-webmvc-4.1.6.RELEASE.jar, file:/usr/local/apache-tomcat-7.0.47/webapps/rest/WEB-INF/lib/validation-api-1.1.0.Final.jar]2015-06-24 11:36:59.663 ERROR 89274 --- [ost-startStop-1] o.s.boot.SpringApplication : Application startup failedjava.lang.NoSuchMethodError: java.lang.reflect.Parameter.isNamePresent()Z at org.springframework.core.StandardReflectionParameterNameDiscoverer.getParameterNames(StandardReflectionParameterNameDiscoverer.java:56) at org.springframework.core.PrioritizedParameterNameDiscoverer.getParameterNames(PrioritizedParameterNameDiscoverer.java:65) at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:182) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1139) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1042) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry$OptimizedBeanTypeRegistry.getFromFactory(BeanTypeRegistry.java:320) at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.get(BeanTypeRegistry.java:162) at org.springframework.boot.autoconfigure.condition.OnBeanCondition.collectBeanNamesForType(OnBeanCondition.java:158) at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getBeanNamesForType(OnBeanCondition.java:147) at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchingBeans(OnBeanCondition.java:119) at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchOutcome(OnBeanCondition.java:94) at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:45) at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:102) at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:190) at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:148) at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:124) at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:318) at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:239) at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:254) at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:94) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:606) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:462) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686) at org.springframework.boot.SpringApplication.run(SpringApplication.java:320) at org.springframework.boot.context.web.SpringBootServletInitializer.run(SpringBootServletInitializer.java:117) at org.springframework.boot.context.web.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:108) at org.springframework.boot.context.web.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:68) at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:175) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5423) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:983) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1660) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:724)By looking at these logs, I have the feeling that something is failing in the auto-magical process of Spring but unfortunately I don't know what and how to fix it. Any help? 解决方案 What version of java are you using? The gradle file indicates you intend to use java 8, but this error indicates you are not...java.lang.NoSuchMethodError: java.lang.reflect.Parameter.isNamePresent()The Parameter class was not introduced until java 8. What version of java is your tomcat using? 这篇关于将Spring Boot RESTful Web服务部署到Tomcat时仍然缺少Web.xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-14 16:53