springboot小筆記
阿新 • • 發佈:2018-07-18
string str end build pub class code run 這樣的
如果默認通過IDEA的springboot 插件布置的 的初始啟動類是這樣的,這種就是一個普通的java類,只能以jar打包
package com.how2java.springboot; 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); } }
假如想以打包成war包, 想放到tomcat 的webapp裏 那麽改成下面這個啟動類
package com.how2java.springboot; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; @SpringBootApplication @ServletComponentScan public class Application extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(Application.class); } public static void main(String[] args) { SpringApplication.run(Application.class, args); } }
springboot小筆記