赞
踩
将 jar 修改为 war
<!-- <packaging>jar</packaging>-->
<packaging>war</packaging>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<!--<scope>provided</scope>-->
<!-- 如果不注释,你会发现main线程运行报404错误,必须使用 spring-boot:run这个命令运行才行。所以我们注释掉-->
</dependency>
<!--添加servlet-api的依赖,用来打war包 -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
1.将
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
修改成
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jdbc</artifactId>
</dependency>
<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>
2.将
<finalName>phoneshow</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
改为
<finalName>phoneshow</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<!--配置springboot入口类-->
<configuration>
<fork>true</fork>
<jvmArguments>Dfile.encoding=UTF-8</jvmArguments>
<!--配置入口类的标签名-->
<mainClass>com.phoneback</mainClass>
</configuration>
</plugin>
</plugins>
</build>
将
public class DemocopyApplication{
public static void main(String[] args) {
SpringApplication.run(DemocopyApplication.class, args);
}
}
修改为
public class DemocopyApplication extends SpringBootServletInitializer{
public static void main(String[] args) {
SpringApplication.run(DemocopyApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder){
return builder.sources(DemocopyApplication.class);
}
}
放在tomcat的webapps文件夹内
双击bin内的startup.bat运行
访问方式:
http://localhost:8080/项目名
修改conf文件夹内的server.xml文件
原来的删除注释内容后显示:
复制一份,将service和engine的名字改成其他的(必须一样),host的appbase修改新名字,将port修改成自己想要的端口号。
要想访问不加后面的项目名加上,如上图:
<Context path="" docBase="phoneshow" reloadable="true" />
docBase是项目名。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。