用tomcat启动spring-boot
两种做法
修改Appcation.java文件
package com.techny.lianmai; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.context.annotation.ComponentScan; @SpringBootApplication @ComponentScan(basePackages = {"com.techny.lianmai.*"}) //指定扫描包路径 public class LianmaiApplication extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(LianmaiApplication.class); } public static void main(String[] args) { SpringApplication.run(LianmaiApplication.class, args); } }
或者添加一个文件ServletInitializer.java
package com.techny.lianmai; 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(LianmaiApplication.class); } }
可以正常进入网页
论读书
睁开眼,书在面前 闭上眼,书在心里
睁开眼,书在面前 闭上眼,书在心里