如何把springboot jar項(xiàng)目 改為war項(xiàng)目
這篇文章主要介紹了如何把springboot jar項(xiàng)目 改為war項(xiàng)目,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
啟動(dòng)類JeewxBootApplication 添加繼承SpringBootServletInitializer
重寫實(shí)現(xiàn)
@SpringBootApplication
public class JeewxBootApplication extends SpringBootServletInitializer {
public final static Logger log = LoggerFactory.getLogger(JeewxBootApplication.class);
public static void main(String[] args) {
ConfigurableApplicationContext application = SpringApplication.run(JeewxBootApplication.class, args);
Environment env = application.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
String path = env.getProperty("server.servlet.context-path");
log.info("\n----------------------------------------------------------\n\t" +
"Application is running! Access URLs:\n\t" +
"Local: \t\thttp://localhost:" + port + path + "/\n\t" +
"External: \thttp://" + ip + ":" + port + path + "/\n\t" +
"----------------------------------------------------------");
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(JeewxBootApplication.class);
}
}
pom文件添加插件
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
pom文件添加依賴
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.0.1</version> <scope>provided</scope> </dependency>
以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
使用idea遠(yuǎn)程調(diào)試jar包的配置過程
這篇文章主要介紹了使用idea遠(yuǎn)程調(diào)試jar包的配置過程,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-09-09
Spring Boot 應(yīng)用程序中配置使用consul的方法
配置是 Spring Boot 應(yīng)用程序中的一部分,主要用于配置服務(wù)端口、應(yīng)用名稱、Consul 服務(wù)發(fā)現(xiàn)以及健康檢查等功能,下面給大家介紹Spring Boot 應(yīng)用程序中配置使用consul,感興趣的朋友一起看看吧2025-04-04
mybatis-plus自定義排序的實(shí)現(xiàn)
本文主要介紹了mybatis-plus自定義排序的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-01-01
springboot 多數(shù)據(jù)源配置不生效遇到的坑及解決
這篇文章主要介紹了springboot 多數(shù)據(jù)源配置不生效遇到的坑及解決,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2021-11-11
SpringBoot定制三種錯(cuò)誤頁面及錯(cuò)誤數(shù)據(jù)方法示例
Spring Boot提供的默認(rèn)異常處理機(jī)制通常并不一定適合我們實(shí)際的業(yè)務(wù)場(chǎng)景,因此,我們通常會(huì)根據(jù)自身的需要對(duì)Spring Boot全局異常進(jìn)行統(tǒng)一定制,例如定制錯(cuò)誤頁面,定制錯(cuò)誤數(shù)據(jù)等。本文主要介紹了SpringBoot三種自定義錯(cuò)誤頁面的實(shí)現(xiàn),快來學(xué)習(xí)吧2021-12-12
SpringBoot自動(dòng)配置之自定義starter的實(shí)現(xiàn)代碼
這篇文章主要介紹了SpringBoot自動(dòng)配置之自定義starter的實(shí)現(xiàn)代碼,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-10-10
使用Feign實(shí)現(xiàn)微服務(wù)間文件下載
這篇文章主要為大家詳細(xì)介紹了使用Feign實(shí)現(xiàn)微服務(wù)間文件下載,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-04-04

