springboot 使用外置tomcat启动
2024-10-07 07:25:21
pom.xml 如下
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1..RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent> <groupId>com.ds</groupId>
<artifactId>ksh</artifactId>
<version>0.0.-SNAPSHOT</version>
<name>ksh</name>
<packaging>war</packaging>
<description>Demo project for Spring Boot</description> <properties>
<java.version>1.8</java.version>
</properties> <dependencies>
<!--web全栈开发-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<!--使用外部tomcat需要把内置的tomcat排除-->
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency> <dependency>
<!--添加springboot-tomcat scope必须时 provided-->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency> <!--测试 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency> <!--使用freemarker必须包-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency> <!--java与mysql连接的jar包驱动程序-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.</version>
</dependency> <!-- mybatis-->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency> <!-- jdbcTemplate -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency> <!-- redis -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency> <!--json格式化-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.</version>
</dependency> </dependencies> <build>
<finalName>ksh_gis</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
<!-- 分离配置文件-->
<!-- <resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>**/*.properties</exclude>
<exclude>**/*.yml</exclude>
</excludes>
</resource>
</resources>-->
</build> </project>
启动类
package com.ds.ksh.v1; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; /*@SpringBootApplication
@MapperScan(basePackages = "com.ds")
public class KshApplication {
public static void main(String[] args) {
SpringApplication.run(KshApplication.class, args);
}
}*/
@SpringBootApplication
public class KshApplication extends SpringBootServletInitializer { public static void main(String[] args) {
SpringApplication.run(KshApplication.class, args);
} @Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(KshApplication.class);
}
}
tomcat部署 tomcat7使用以上版本不然有时候启动肯有问题
删除ROOT --> 将war复制到webapp下 --> 修改项目名字为ROOT.war
这样的好处是不用再配置别的东西直接启动就能访问
最新文章
- c# TimeSpan
- OpenCV整体的模块架构
- Python 的 pyinotify 模块 监控文件夹和文件的变动
- java反射机制一个例子
- WhatFontIs - 字体百科全书,没有不认识的字体
- 收藏的一段关于java大数运算的代码
- 完成OSS.Http底层HttpClient重构封装 支持标准库
- null == undefined ?
- gcc &; gdb &; make 定义与区别
- 使用gogs搭建git私有仓库
- es6的基本数据详解
- 如何将Drawable转为Bitmap?
- docker 学习(九) docker部署静态网站
- Tesseract-OCR 3.05 多过语言文字识别(运行程序+中英日韩语言包)
- emulator: ERROR: x86 emulation currently requires hardware acceleration!Please ensure Intel HAXM is properly installed and usable.CPU acceleration status: HAX kernel module is not installed!
- 2017 jq 总结
- 怎么成为asp.net大神!!!!!!!!!!!!!!!!!!!怎么成为asp.net大神!!!!!!!!!!!!!!!!!!!
- 关于linux系统如何实现fork的研究(二)【转】
- TF卡.之前的(20180923)
- [OpenJudge8471][划分DP]切割回文
热门文章
- pyinstaller打包总结
- java.lang.IllegalStateException: No output folder
- AIX中物理卷管理
- 【转】sysctl命令及改变net.ipv4.ip_forward = 1方法
- 安装CRMEasy步骤
- 模拟赛小结:2014-2015 ACM-ICPC, NEERC, Southern Subregional Contest
- Linux查看某进程的线程
- MyBatis主配置文件(转载)
- inotify.sh脚本范例
- 私有ip地址知多少?