Tomcat项目war包部署
spring boot 只支持tomcat 8.5 以上版本
(如果类上加了虚拟路径,可以单独用一个类来作为打开首页的请求,在类上不加请求)
- 打开域名加载的首页请求,必须是 /
2、idea中打包(Maven项目)
- tomcat配置
- 将war包复制到tomcat的D:\apache-tomcat-8.5.34-windows-x64\apache-tomcat-8.5.34\webapps下,
- 在D:\apache-tomcat-8.5.34-windows-x64\apache-tomcat-8.5.34\bin下的startup启动tomcat,:会生成以war包名称一致的文件夹
- 打开D:\apache-tomcat-8.5.34-windows-x64\apache-tomcat-8.5.34\conf\server.xml
- 为了实现域名直接访问
①去端口:将tomcat的默认端口端口改为80
②去项目名称
在Host中添加以下代码:
- 重启tomcat
- 在服务器浏览器输入127.0.0.1或者localhost即可访问主页
二、如果是要用域名打开,则将服务器的IP放在server.xml
中相应位置即可:
Springboot(Gradle)注意:部署外部tomcat去除自带的tomcat
1、
org.springframework.boot:spring-boot-starter-web 内置了tomcat容器,
// 因为要部署到tomcat所以要在打包war的时候将其排除出去,所以使用了providedRuntime
compile("org.springframework.boot:spring-boot-starter-web:1.5.2.RELEASE")
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat:1.5.2.RELEASE'
Springboot(Maven)注意:部署外部tomcat去除自带的tomcat
第一种:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
第二种:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
2、启动类只有一个的springboot2.0以下
2-1、启动类有两个,不用继承,保持原样
还没有评论,来说两句吧...