1.我按照网上的教程将Spring boot项目改成war进行打包,然后部署在本机的tomcat7.0上,启动tomcat,访问项目时发现无法访问项目了.
2.pom文件的内容
4.0.0
com.ming.wei.yue
bargain
war
0.0.1-SNAPSHOT
org.springframework.boot
spring-boot-starter-parent
1.4.2.RELEASE
UTF-8
UTF-8
1.8
com.ming.wei.yue.ApplicationStart
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-devtools
true
org.springframework.boot
spring-boot-starter-tomcat
provided
org.apache.tomcat.embed
tomcat-embed-jasper
provided
javax.servlet
jstl
org.springframework.boot
spring-boot-maven-plugin
3.启动类配置
package com.ming.wei.yue;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
@SpringBootApplication
public class ApplicationStart extends SpringBootServletInitializer{
public static void main(String[] args){
SpringApplication.run(ApplicationStart.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(ApplicationStart.class);
}
}
4.controller类
package com.ming.wei.yue.action;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class Bargain {
@RequestMapping(value="/test")
@ResponseBody
public String test(){
return "ECS1";
}
}
5.配置文件的信息

6.eclipse上直接使用maven install命令打包


将这个war包放到本机的tomcat的webapps目录下面,并且改名成demo.war

7.启动Tomcat7

8.测试访问,访问报错

请教我这是哪里有问题啊?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
你的application.yml中配置的server.port配置的是spring boot内置的tomcat的端口号, 打成war包部署在独立的tomcat上之后, 你配置的server.port是不起作用的.
从你截图日志看 tomcat已经启动成功 端口是8080
http://127.0.0.1:8080/demo/test