额,简单的说啊。只是为了记录一下本身遇到的问题,记录下来方便之后排查,先说spring Boot的打包。通常咱们在maven里面这样配置java
<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <fork>true</fork> </configuration> </plugin>
方便打包成可运行的jar包,可是我感受每次这样打包太大了。每次上传部署太浪费时间了。因此我直接改为普通的打包方式。web
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.4</version> <configuration> <archive> <manifest> <mainClass>com.turing.cloud.CloudApplication</mainClass> </manifest> </archive> </configuration> </plugin>
而后使用redis
mvn dependency:copy-dependencies -DoutputDirectory=lib -DincludeScope=runtime
把依赖包复制到lib下面。第一次部署的时候上传lib,以后就只须要上传项目自己了。而后直接spring
java -jar -Djava.ext.dirs=lib app.jar
没想到启都起不起来。第一步是报错关于Tomcat的。apache
org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:137) ~[spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537) ~[spring-context-4.3.14.RELEASE.jar:4.3.14.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE] at com.turing.cloud.CloudApplication.main(CloudApplication.java:12) [cloud-webcontroller-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT] Caused by: org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:123) ~[spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE] at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:84) ~[spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE] at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:554) ~[spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE] at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:179) ~[spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:164) ~[spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:134) ~[spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE] ... 8 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) ~[tomcat-embed-core-8.5.27.jar:8.5.27] at org.apache.catalina.startup.Tomcat.start(Tomcat.java:367) ~[tomcat-embed-core-8.5.27.jar:8.5.27] at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:99) ~[spring-boot-1.5.10.RELEASE.jar:1.5.10.RELEASE] ... 13 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) ~[tomcat-embed-core-8.5.27.jar:8.5.27] at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:793) ~[tomcat-embed-core-8.5.27.jar:8.5.27] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-embed-core-8.5.27.jar:8.5.27] ... 15 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) ~[tomcat-embed-core-8.5.27.jar:8.5.27] at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422) ~[tomcat-embed-core-8.5.27.jar:8.5.27] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-embed-core-8.5.27.jar:8.5.27] ... 17 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) ~[tomcat-embed-core-8.5.27.jar:8.5.27] at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) ~[tomcat-embed-core-8.5.27.jar:8.5.27] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-embed-core-8.5.27.jar:8.5.27] ... 19 common frames omitted
后来才知道里面有个servlet-api-2.5冲突了。因而删掉。再次启动。api
结果……不读取个人yml配置了。因而加上启动参数再次启动tomcat
java -jar -Djava.ext.dirs=lib -Dspring.profiles.active=test app.jar
这样我指定了profile了。日志也显示使用test profile了。可是以后感受仍是没有读取配置,由于我server端口写的8088,启动完成仍是8080.因而使用eclipse 远程调试。。。。终于在 org.springframework.boot.env.YamlPropertySourceLoader 发型这样一行。session
if (ClassUtils.isPresent("org.yaml.snakeyaml.Yaml", null))
真相大白了,缺包嘛。因而maven里面加上app
<dependency> <groupId>org.yaml</groupId> <artifactId>snakeyaml</artifactId> </dependency>
OK,终于正常了。还有一个关于spring redis session的坑,再写。。。。。eclipse