Java终端失败,eclipse工作

时间:2018-01-06 08:23:53

标签: java linux spring tomcat

我试图从终端运行一个jar文件(打包一个),但它仍然失败。 它在eclipse中运行完全正常但是当我尝试从终端运行它时它失败了。 该应用程序只是一个小型服务,因为我学习弹簧框架。 这是我在终端获得的内容:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                        

2018-01-05 11:23:19.793  INFO 20547 --- [           main] one.demo.SpringbootApplication           : Starting SpringbootApplication on mumen-S400CA with PID 20547 (/home/mumen/Downloads/demo/target/. started by mumen in /home/mumen/Downloads/demo/target)
2018-01-05 11:23:19.799  INFO 20547 --- [           main] one.demo.SpringbootApplication           : No active profile set, falling back to default profiles: default
2018-01-05 11:23:20.090  INFO 20547 --- [           main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@42505474: startup date [Fri Jan 05 11:23:20 GST 2018]; root of context hierarchy
2018-01-05 11:23:20.637  WARN 20547 --- [           main] .i.s.PathMatchingResourcePatternResolver : Cannot search for matching files underneath URL [rsrc:one/demo/] because it does not correspond to a directory in the file system

java.io.FileNotFoundException: URL [rsrc:one/demo/] cannot be resolved to absolute file path because it does not reside in the file system: rsrc:one/demo/
    at org.springframework.util.ResourceUtils.getFile(ResourceUtils.java:217) ~[jar:rsrc:spring-core-5.0.2.RELEASE.jar!/:na]
    at org.springframework.core.io.AbstractFileResolvingResource.getFile(AbstractFileResolvingResource.java:70) ~[jar:rsrc:spring-core-5.0.2.RELEASE.jar!/:na]
    at org.springframework.core.io.UrlResource.getFile(UrlResource.java:225) ~[jar:rsrc:spring-core-5.0.2.RELEASE.jar!/:na]
    at org.springframework.core.io.support.PathMatchingResourcePatternResolver.doFindPathMatchingFileResources(PathMatchingResourcePatternResolver.java:699) [jar:rsrc:spring-core-5.0.2.RELEASE.jar!/:na]
    at org.springframework.web.context.support.ServletContextResourcePatternResolver.doFindPathMatchingFileResources(ServletContextResourcePatternResolver.java:92) [jar:rsrc:spring-web-5.0.2.RELEASE.jar!/:na]
    at org.springframework.core.io.support.PathMatchingResourcePatternResolver.findPathMatchingResources(PathMatchingResourcePatternResolver.java:512) [jar:rsrc:spring-core-5.0.2.RELEASE.jar!/:na]
    at org.springframework.core.io.support.PathMatchingResourcePatternResolver.getResources(PathMatchingResourcePatternResolver.java:282) [jar:rsrc:spring-core-5.0.2.RELEASE.jar!/:na]
    at org.springframework.context.support.AbstractApplicationContext.getResources(AbstractApplicationContext.java:1305) [jar:rsrc:spring-context-5.0.2.RELEASE.jar!/:na]
    at org.springframework.context.support.GenericApplicationContext.getResources(GenericApplicationContext.java:238) [jar:rsrc:spring-context-5.0.2.RELEASE.jar!/:na]
    at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.scanCandidateComponents(ClassPathScanningCandidateComponentProvider.java:421) [jar:rsrc:spring-context-5.0.2.RELEASE.jar!/:na]
    at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:316) [jar:rsrc:spring-context-5.0.2.RELEASE.jar!/:na]
    at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:275) [jar:rsrc:spring-context-5.0.2.RELEASE.jar!/:na]
    at org.springframework.context.annotation.ComponentScanAnnotationParser.parse(ComponentScanAnnotationParser.java:132) [jar:rsrc:spring-context-5.0.2.RELEASE.jar!/:na]
    at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:284) [jar:rsrc:spring-context-5.0.2.RELEASE.jar!/:na]
    at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:241) [jar:rsrc:spring-context-5.0.2.RELEASE.jar!/:na]
    at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:198) [jar:rsrc:spring-context-5.0.2.RELEASE.jar!/:na]
    at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:166) [jar:rsrc:spring-context-5.0.2.RELEASE.jar!/:na]
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:316) [jar:rsrc:spring-context-5.0.2.RELEASE.jar!/:na]
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:233) [jar:rsrc:spring-context-5.0.2.RELEASE.jar!/:na]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273) [jar:rsrc:spring-context-5.0.2.RELEASE.jar!/:na]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93) [jar:rsrc:spring-context-5.0.2.RELEASE.jar!/:na]
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:693) [jar:rsrc:spring-context-5.0.2.RELEASE.jar!/:na]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531) [jar:rsrc:spring-context-5.0.2.RELEASE.jar!/:na]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:138) [jar:rsrc:spring-boot-2.0.0.BUILD-SNAPSHOT.jar!/:na]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:751) [jar:rsrc:spring-boot-2.0.0.BUILD-SNAPSHOT.jar!/:na]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:387) [jar:rsrc:spring-boot-2.0.0.BUILD-SNAPSHOT.jar!/:na]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [jar:rsrc:spring-boot-2.0.0.BUILD-SNAPSHOT.jar!/:na]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1245) [jar:rsrc:spring-boot-2.0.0.BUILD-SNAPSHOT.jar!/:na]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1233) [jar:rsrc:spring-boot-2.0.0.BUILD-SNAPSHOT.jar!/:na]
    at one.demo.SpringbootApplication.main(SpringbootApplication.java:10) [rsrc:./:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_151]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_151]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_151]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_151]
    at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58) [spring-boot.jar:na]

2018-01-05 11:23:59.663  INFO 20547 --- [           main] o.h.v.i.engine.ValidatorFactoryImpl      : HV000238: Temporal validation tolerance set to 0.
2018-01-05 11:24:04.427  INFO 20547 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8085 (http)
2018-01-05 11:24:05.130  INFO 20547 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2018-01-05 11:24:05.198  INFO 20547 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.23
2018-01-05 11:24:05.559  INFO 20547 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib/amd64:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib]
2018-01-05 11:24:06.720 ERROR 20547 --- [cat-startStop-1] org.apache.catalina.core.ContainerBase   : A child container failed during start

java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]
    at java.util.concurrent.FutureTask.report(FutureTask.java:122) [na:1.8.0_151]
    at java.util.concurrent.FutureTask.get(FutureTask.java:192) [na:1.8.0_151]
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:939) ~[jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:872) [jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419) [jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409) [jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_151]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_151]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_151]
    at java.lang.Thread.run(Thread.java:748) [na:1.8.0_151]
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) [jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    ... 6 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to initialize component [org.apache.catalina.webresources.StandardRoot@6f73792a]
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:113) [jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140) [jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4860) ~[jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4995) ~[jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    ... 6 common frames omitted
Caused by: java.lang.Error: factory already defined
    at java.net.URL.setURLStreamHandlerFactory(URL.java:1112) ~[na:1.8.0_151]
    at org.apache.catalina.webresources.TomcatURLStreamHandlerFactory.<init>(TomcatURLStreamHandlerFactory.java:130) ~[jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    at org.apache.catalina.webresources.TomcatURLStreamHandlerFactory.getInstanceInternal(TomcatURLStreamHandlerFactory.java:53) ~[jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    at org.apache.catalina.webresources.TomcatURLStreamHandlerFactory.register(TomcatURLStreamHandlerFactory.java:77) ~[jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    at org.apache.catalina.webresources.StandardRoot.registerURLStreamHandlerFactory(StandardRoot.java:699) ~[jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    at org.apache.catalina.webresources.StandardRoot.initInternal(StandardRoot.java:682) ~[jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:107) [jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    ... 10 common frames omitted

2018-01-05 11:24:06.722 ERROR 20547 --- [           main] org.apache.catalina.core.ContainerBase   : A child container failed during start

java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost]]
    at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[na:1.8.0_151]
    at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[na:1.8.0_151]
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:939) ~[jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) [jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422) [jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:793) [jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    at org.apache.catalina.startup.Tomcat.start(Tomcat.java:367) [jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:98) [jar:rsrc:spring-boot-2.0.0.BUILD-SNAPSHOT.jar!/:na]
    at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:84) [jar:rsrc:spring-boot-2.0.0.BUILD-SNAPSHOT.jar!/:na]
    at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:413) [jar:rsrc:spring-boot-2.0.0.BUILD-SNAPSHOT.jar!/:na]
    at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:176) [jar:rsrc:spring-boot-2.0.0.BUILD-SNAPSHOT.jar!/:na]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:177) [jar:rsrc:spring-boot-2.0.0.BUILD-SNAPSHOT.jar!/:na]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:150) [jar:rsrc:spring-boot-2.0.0.BUILD-SNAPSHOT.jar!/:na]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) [jar:rsrc:spring-context-5.0.2.RELEASE.jar!/:na]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:138) [jar:rsrc:spring-boot-2.0.0.BUILD-SNAPSHOT.jar!/:na]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:751) [jar:rsrc:spring-boot-2.0.0.BUILD-SNAPSHOT.jar!/:na]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:387) [jar:rsrc:spring-boot-2.0.0.BUILD-SNAPSHOT.jar!/:na]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [jar:rsrc:spring-boot-2.0.0.BUILD-SNAPSHOT.jar!/:na]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1245) [jar:rsrc:spring-boot-2.0.0.BUILD-SNAPSHOT.jar!/:na]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1233) [jar:rsrc:spring-boot-2.0.0.BUILD-SNAPSHOT.jar!/:na]
    at one.demo.SpringbootApplication.main(SpringbootApplication.java:10) [rsrc:./:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_151]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_151]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_151]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_151]
    at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58) [spring-boot.jar:na]
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) [jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419) ~[jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409) ~[jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_151]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_151]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_151]
    at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_151]
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:948) ~[jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:872) ~[jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    ... 6 common frames omitted

2018-01-05 11:24:06.723  WARN 20547 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
2018-01-05 11:24:06.739  INFO 20547 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-01-05 11:24:06.743 ERROR 20547 --- [           main] o.s.boot.SpringApplication               : Application startup failed

org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:153) ~[jar:rsrc:spring-boot-2.0.0.BUILD-SNAPSHOT.jar!/:na]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[jar:rsrc:spring-context-5.0.2.RELEASE.jar!/:na]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:138) ~[jar:rsrc:spring-boot-2.0.0.BUILD-SNAPSHOT.jar!/:na]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:751) [jar:rsrc:spring-boot-2.0.0.BUILD-SNAPSHOT.jar!/:na]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:387) [jar:rsrc:spring-boot-2.0.0.BUILD-SNAPSHOT.jar!/:na]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [jar:rsrc:spring-boot-2.0.0.BUILD-SNAPSHOT.jar!/:na]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1245) [jar:rsrc:spring-boot-2.0.0.BUILD-SNAPSHOT.jar!/:na]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1233) [jar:rsrc:spring-boot-2.0.0.BUILD-SNAPSHOT.jar!/:na]
    at one.demo.SpringbootApplication.main(SpringbootApplication.java:10) [rsrc:./:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_151]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_151]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_151]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_151]
    at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58) [spring-boot.jar:na]
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
    at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:117) ~[jar:rsrc:spring-boot-2.0.0.BUILD-SNAPSHOT.jar!/:na]
    at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:84) ~[jar:rsrc:spring-boot-2.0.0.BUILD-SNAPSHOT.jar!/:na]
    at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:413) ~[jar:rsrc:spring-boot-2.0.0.BUILD-SNAPSHOT.jar!/:na]
    at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:176) ~[jar:rsrc:spring-boot-2.0.0.BUILD-SNAPSHOT.jar!/:na]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:177) ~[jar:rsrc:spring-boot-2.0.0.BUILD-SNAPSHOT.jar!/:na]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:150) ~[jar:rsrc:spring-boot-2.0.0.BUILD-SNAPSHOT.jar!/:na]
    ... 13 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardServer[-1]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) ~[jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    at org.apache.catalina.startup.Tomcat.start(Tomcat.java:367) ~[jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:98) ~[jar:rsrc:spring-boot-2.0.0.BUILD-SNAPSHOT.jar!/:na]
    ... 18 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Tomcat]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) ~[jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:793) ~[jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    ... 20 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) ~[jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422) ~[jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    ... 22 common frames omitted
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:948) ~[jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) ~[jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[jar:rsrc:tomcat-embed-core-8.5.23.jar!/:na]
    ... 24 common frames omitted

这里是主要班级:

package one.demo;

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

@SpringBootApplication
public class SpringbootApplication {

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

这是控制器:

package one.demo;

import java.util.ArrayList;
import java.util.List;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class BooksController {

    @GetMapping("/books")
    public List<Book> GetAllBooks(){

         List<Book> books =  new ArrayList<Book>();
         books.add(new Book(11, "mo2men book", "mo2men"));
         return books;
    }

}

这是书类:

package one.demo;

public class Book {
    long id;
    String name;
    String author;
    public long getId() {
        return id;
    }
    public String getName() {
        return name;
    }
    public String getAuthor() {
        return author;
    }
    public Book(int id, String name, String author) {
        super();
        this.id = id;
        this.name = name;
        this.author = author;
    }

    @Override
    public String toString() {
        return "Book [id=" + id + ", name=" + name + ", author=" + author + "]";
    }


}

这里是pom.xml:

<?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>one</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>demo</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.0.BUILD-SNAPSHOT</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>https://repo.spring.io/snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>https://repo.spring.io/snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
        <pluginRepository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>


</project>

1 个答案:

答案 0 :(得分:0)

尝试将此依赖项添加到您的POM。

<dependency>
    <groupId>org.apache.tomcat.embed</groupId>
    <artifactId>tomcat-embed-jasper</artifactId>
    <scope>provided</scope>
</dependency>