在controller包下新建appController类
package controller; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.support.SpringBootServletInitializer; @SpringBootApplication public class appController extends SpringBootServletInitializer { public static void main(String[] args){ SpringApplication.run(appController.class,args); } @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { return builder.sources(appController.class); } }
新建indexController
新建proController类
启动appController类中的main函数
浏览器输入:localhost:8080/proo
浏览器输入:localhost:8080/index
@SpringBootApplication public class UdeamApplication { public static void main(String[] args) { SpringApplication.run(UdeamApplication.class, args); } }
开启springboot配置注解 ,项目启动入口,用来启动spring容器 , 启动tomcat , 其他包必须与此类在同级目录或者子包下
以上是如何在springboot项目中启动main函数的详细内容。更多信息请关注PHP中文网其他相关文章!