idea使用外置tomcat配置springboot詳細(xì)步驟
- 創(chuàng)建一個(gè)maven項(xiàng)目
- 導(dǎo)入springboot依賴,注意底下注釋部分
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.znsd.springboot</groupId>
<artifactId>springboot-jsp</artifactId>
<version>1.0-SNAPSHOT</version>
<!-- 一定要聲明war包 -->
<packaging>war</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.12.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- 去除springboot默認(rèn)tomcat依賴,讓其在生成war包時(shí)無效, -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<!--在編譯和測試有效,生成war包時(shí)無效-->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>


完成下圖操作保存即可

配置tomcat啟動(dòng)項(xiàng)




配置視圖解析器

創(chuàng)建一個(gè)springboot主程序
@SpringBootApplication
public class SpringBootMain {
public static void main(String[] args) {
SpringApplication.run(SpringBootMain.class,args);
}
}
必須編寫一個(gè)SpringBootServletInitializer的子類,并調(diào)用configure方法里面的固定寫法
public class ServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
//傳入SpringBoot的主程序,
return application.sources(SpringBootMain.class);
}
}
然后啟動(dòng)tomcat,控制臺(tái)輸出了spring就啟動(dòng)成功了

到此這篇關(guān)于idea配置springboot使用外置tomcat詳細(xì)步驟的文章就介紹到這了,更多相關(guān)idea配置springboot內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
java selenium Selenium IDE介紹及用法
本文主要介紹java selenium Selenium IDE,這里整理了相關(guān)資料和介紹如何安裝 Selenium IDE和使用方法,有需要的小伙伴可以參考下2016-08-08
MyBatis嵌套查詢collection報(bào)錯(cuò):org.apache.ibatis.exceptions.TooMany
本文主要介紹了MyBatis嵌套查詢collection報(bào)錯(cuò):org.apache.ibatis.exceptions.TooManyResultsException,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2024-09-09

