idea怎么使用外置tomcat配置springboot

idea怎么使用外置tomcat配置springboot

本篇内容介绍了“idea怎么使用外置tomcat配置springboot”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

  • 创建一个maven项目

  • 导入springboot依赖,注意底下注释部分

4.0.0com.znsd.springbootspringboot-jsp1.0-SNAPSHOTwarorg.springframework.bootspring-boot-starter-parent2.3.12.RELEASEorg.springframework.bootspring-boot-starter-weborg.springframework.bootspring-boot-starter-tomcatprovidedorg.springframework.bootspring-boot-starter-testtestorg.junit.vintagejunit-vintage-engineorg.springframework.bootspring-boot-maven-plugin

完成下图操作保存即可

配置tomcat启动项

配置视图解析器

创建一个springboot主程序

@SpringBootApplicationpublicclassSpringBootMain{publicstaticvoidmain(String[]args){SpringApplication.run(SpringBootMain.class,args);}}

必须编写一个SpringBootServletInitializer的子类,并调用configure方法里面的固定写法

publicclassServletInitializerextendsSpringBootServletInitializer{@OverrideprotectedSpringApplicationBuilderconfigure(SpringApplicationBuilderapplication){//传入SpringBoot的主程序,returnapplication.sources(SpringBootMain.class);}}

然后启动tomcat,控制台输出了spring就启动成功了

“idea怎么使用外置tomcat配置springboot”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注恰卡编程网网站,小编将为大家输出更多高质量的实用文章!

发布于 2022-04-03 22:33:50
分享
海报
35
上一篇:怎么用Springboot+mybatis-plus+注解实现数据权限隔离 下一篇:SpringBoot怎么动态修改Scheduled
目录

    忘记密码?

    图形验证码