idea下springboot打包成jar包和war包,并且可以在外部tomcat下运行访问到
接着上一章走呗:http://www.cnblogs.com/sxdcgaq8080/p/7712874.html
然后声明一点,下面打包的过程中,scope一直都是使用默认的范围
<!--用于编译jsp-->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<!--<scope>runtime</scope>-->
</dependency>
把上一章创建好的spring boot项目打包成jar包和war包
【jar和war的区别就是:<packaging>标签中的值更改就行 如下图】
=====================================================================================================================================
好了,这里先打成jar包
使用maven的插件打包
此时打包出来是有默认的名称的jar包。然后在命令行下 运行起这个jar包。当然,jar包名字你需要去上面target路径下去拷贝一下。【是不是很麻烦!!】
然后访问一下jsp页面,因为我方法中加了打印,可以看到进来了
但是页面访问不到:
然后去jar包中查看一下,是因为jar包中没有把webapp下的页面文件等打包进去,当然访问找不到页面了【如果你想jar包也可以打包webapp下的页面的话,可以:http://www.cnblogs.com/sxdcgaq8080/p/7715427.html】
好吧,jar包既然打包不成功访问,那就打包war包:就把jar改成war就好了
【注意:如果嫌弃上面需要去拷贝jar包名字麻烦,想打包出来的名字是自定义的,在build下 规定即可】
在打包成war包
看看 打包出来的war包名字是不是自定义的
然后再运行war包
这下是可以访问到的了。
看看war包下,是已经将页面文件打包进去了。
=======================================================================================================================================
好了 打包暂时打包成功了,直接拿着上面的war包放到一个外部的tomcat中跑起来试一下:
启动一下:
不成功,按照下面 两步走,解决当前这个在外部tomcat没办法运行起来并访问的问题:
第一步:
新建一个SpringBootStartApplication 继承自 SpringBootServletInitializer
作用:因为在外部容器部署的话,就不能依赖于Application的main函数了,而是要以类似于web.xml文件配置的方式来启动Spring应用上下文,
此时我们需要在启动类中继承SpringBootServletInitializer并实现configure方法,这个类的作用与在web.xml中配置负责初始化Spring应用上下文的监听器作用类似
【注意】:这个新建的类,与springboot的启动类是同级的
package com.sxd; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer; public class SpringBootStartApplication extends SpringBootServletInitializer{@Override
</span><span style="color: #0000ff">protected</span><span style="color: #000000"> SpringApplicationBuilder configure(SpringApplicationBuilder application) {
</span><span style="color: #0000ff">return</span> application.sources(FirstdemoApplication.<span style="color: #0000ff">class</span><span style="color: #000000">);
}
}
第二步:
修改pom.xml文件,这里有两种方法,但是最终的目的都是让springboot内嵌的tomcat在运行时不起作用而已。
两种方法任选一种!!!
方法1:
此时的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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion><span style="color: #0000ff"><</span><span style="color: #800000">groupId</span><span style="color: #0000ff">></span>com.sxd<span style="color: #0000ff"></</span><span style="color: #800000">groupId</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">artifactId</span><span style="color: #0000ff">></span>firstdemo<span style="color: #0000ff"></</span><span style="color: #800000">artifactId</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">version</span><span style="color: #0000ff">></span>0.0.1-SNAPSHOT<span style="color: #0000ff"></</span><span style="color: #800000">version</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">packaging</span><span style="color: #0000ff">></span>war<span style="color: #0000ff"></</span><span style="color: #800000">packaging</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">name</span><span style="color: #0000ff">></span>firstdemo<span style="color: #0000ff"></</span><span style="color: #800000">name</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">description</span><span style="color: #0000ff">></span>Demo project for Spring Boot<span style="color: #0000ff"></</span><span style="color: #800000">description</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">parent</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">groupId</span><span style="color: #0000ff">></span>org.springframework.boot<span style="color: #0000ff"></</span><span style="color: #800000">groupId</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">artifactId</span><span style="color: #0000ff">></span>spring-boot-starter-parent<span style="color: #0000ff"></</span><span style="color: #800000">artifactId</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">version</span><span style="color: #0000ff">></span>1.5.8.RELEASE<span style="color: #0000ff"></</span><span style="color: #800000">version</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">relativePath</span><span style="color: #0000ff">/></span> <span style="color: #008000"><!--</span><span style="color: #008000"> lookup parent from repository </span><span style="color: #008000">--></span>
<span style="color: #0000ff"></</span><span style="color: #800000">parent</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">properties</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">project.build.sourceEncoding</span><span style="color: #0000ff">></span>UTF-8<span style="color: #0000ff"></</span><span style="color: #800000">project.build.sourceEncoding</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">project.reporting.outputEncoding</span><span style="color: #0000ff">></span>UTF-8<span style="color: #0000ff"></</span><span style="color: #800000">project.reporting.outputEncoding</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">java.version</span><span style="color: #0000ff">></span>1.8<span style="color: #0000ff"></</span><span style="color: #800000">java.version</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"></</span><span style="color: #800000">properties</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">dependencies</span><span style="color: #0000ff">></span>
<span style="color: #008000"><!--</span><span style="color: #008000">web支持</span><span style="color: #008000">--></span>
<span style="color: #0000ff"><</span><span style="color: #800000">dependency</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">groupId</span><span style="color: #0000ff">></span>org.springframework.boot<span style="color: #0000ff"></</span><span style="color: #800000">groupId</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">artifactId</span><span style="color: #0000ff">></span>spring-boot-starter-web<span style="color: #0000ff"></</span><span style="color: #800000">artifactId</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"></</span><span style="color: #800000">dependency</span><span style="color: #0000ff">></span>
<span style="color: #008000"><!--</span><span style="color: #008000">jsp页面使用jstl标签</span><span style="color: #008000">--></span>
<span style="color: #0000ff"><</span><span style="color: #800000">dependency</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">groupId</span><span style="color: #0000ff">></span>javax.servlet<span style="color: #0000ff"></</span><span style="color: #800000">groupId</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">artifactId</span><span style="color: #0000ff">></span>jstl<span style="color: #0000ff"></</span><span style="color: #800000">artifactId</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"></</span><span style="color: #800000">dependency</span><span style="color: #0000ff">></span> <span style="color: #008000"><!--</span><span style="color: #008000">用于编译jsp</span><span style="color: #008000">--></span>
<span style="color: #0000ff"><</span><span style="color: #800000">dependency</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">groupId</span><span style="color: #0000ff">></span>org.apache.tomcat.embed<span style="color: #0000ff"></</span><span style="color: #800000">groupId</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">artifactId</span><span style="color: #0000ff">></span>tomcat-embed-jasper<span style="color: #0000ff"></</span><span style="color: #800000">artifactId</span><span style="color: #0000ff">></span>
<span style="color: #008000"><!--</span><span style="color: #008000"><scope>provided</scope></span><span style="color: #008000">--></span>
<span style="color: #0000ff"></</span><span style="color: #800000">dependency</span><span style="color: #0000ff">></span>
<span style="color: #008000"><!--</span><span style="color: #008000">声明spring boot内嵌tomcat的作用范围 在运行时不起作用</span><span style="color: #008000">--></span>
<span style="color: #0000ff"><</span><span style="color: #800000">dependency</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">groupId</span><span style="color: #0000ff">></span>org.springframework.boot<span style="color: #0000ff"></</span><span style="color: #800000">groupId</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">artifactId</span><span style="color: #0000ff">></span>spring-boot-starter-tomcat<span style="color: #0000ff"></</span><span style="color: #800000">artifactId</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">scope</span><span style="color: #0000ff">></span>provided<span style="color: #0000ff"></</span><span style="color: #800000">scope</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"></</span><span style="color: #800000">dependency</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">dependency</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">groupId</span><span style="color: #0000ff">></span>org.springframework.boot<span style="color: #0000ff"></</span><span style="color: #800000">groupId</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">artifactId</span><span style="color: #0000ff">></span>spring-boot-starter-test<span style="color: #0000ff"></</span><span style="color: #800000">artifactId</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">scope</span><span style="color: #0000ff">></span>test<span style="color: #0000ff"></</span><span style="color: #800000">scope</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"></</span><span style="color: #800000">dependency</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"></</span><span style="color: #800000">dependencies</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">build</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">plugins</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">plugin</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">groupId</span><span style="color: #0000ff">></span>org.springframework.boot<span style="color: #0000ff"></</span><span style="color: #800000">groupId</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">artifactId</span><span style="color: #0000ff">></span>spring-boot-maven-plugin<span style="color: #0000ff"></</span><span style="color: #800000">artifactId</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"></</span><span style="color: #800000">plugin</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"></</span><span style="color: #800000">plugins</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">finalName</span><span style="color: #0000ff">></span>firstDemo<span style="color: #0000ff"></</span><span style="color: #800000">finalName</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"></</span><span style="color: #800000">build</span><span style="color: #0000ff">></span>
</project>
好了 这两步完成,就可以按照上面的打包过程,打包为war包,然后放在外部的tomcat下,start.bat就可以访问了。
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
方法2:
此时的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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion><span style="color: #0000ff"><</span><span style="color: #800000">groupId</span><span style="color: #0000ff">></span>com.sxd<span style="color: #0000ff"></</span><span style="color: #800000">groupId</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">artifactId</span><span style="color: #0000ff">></span>firstdemo<span style="color: #0000ff"></</span><span style="color: #800000">artifactId</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">version</span><span style="color: #0000ff">></span>0.0.1-SNAPSHOT<span style="color: #0000ff"></</span><span style="color: #800000">version</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">packaging</span><span style="color: #0000ff">></span>war<span style="color: #0000ff"></</span><span style="color: #800000">packaging</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">name</span><span style="color: #0000ff">></span>firstdemo<span style="color: #0000ff"></</span><span style="color: #800000">name</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">description</span><span style="color: #0000ff">></span>Demo project for Spring Boot<span style="color: #0000ff"></</span><span style="color: #800000">description</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">parent</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">groupId</span><span style="color: #0000ff">></span>org.springframework.boot<span style="color: #0000ff"></</span><span style="color: #800000">groupId</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">artifactId</span><span style="color: #0000ff">></span>spring-boot-starter-parent<span style="color: #0000ff"></</span><span style="color: #800000">artifactId</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">version</span><span style="color: #0000ff">></span>1.5.8.RELEASE<span style="color: #0000ff"></</span><span style="color: #800000">version</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">relativePath</span><span style="color: #0000ff">/></span> <span style="color: #008000"><!--</span><span style="color: #008000"> lookup parent from repository </span><span style="color: #008000">--></span>
<span style="color: #0000ff"></</span><span style="color: #800000">parent</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">properties</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">project.build.sourceEncoding</span><span style="color: #0000ff">></span>UTF-8<span style="color: #0000ff"></</span><span style="color: #800000">project.build.sourceEncoding</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">project.reporting.outputEncoding</span><span style="color: #0000ff">></span>UTF-8<span style="color: #0000ff"></</span><span style="color: #800000">project.reporting.outputEncoding</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">java.version</span><span style="color: #0000ff">></span>1.8<span style="color: #0000ff"></</span><span style="color: #800000">java.version</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"></</span><span style="color: #800000">properties</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">dependencies</span><span style="color: #0000ff">></span>
<span style="color: #008000"><!--</span><span style="color: #008000">web支持</span><span style="color: #008000">--></span>
<span style="color: #0000ff"><</span><span style="color: #800000">dependency</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">groupId</span><span style="color: #0000ff">></span>org.springframework.boot<span style="color: #0000ff"></</span><span style="color: #800000">groupId</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">artifactId</span><span style="color: #0000ff">></span>spring-boot-starter-web<span style="color: #0000ff"></</span><span style="color: #800000">artifactId</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">exclusions</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">exclusion</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">groupId</span><span style="color: #0000ff">></span>org.springframework.boot<span style="color: #0000ff"></</span><span style="color: #800000">groupId</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">artifactId</span><span style="color: #0000ff">></span>spring-boot-starter-tomcat<span style="color: #0000ff"></</span><span style="color: #800000">artifactId</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"></</span><span style="color: #800000">exclusion</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"></</span><span style="color: #800000">exclusions</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"></</span><span style="color: #800000">dependency</span><span style="color: #0000ff">></span>
<span style="color: #008000"><!--</span><span style="color: #008000">jsp页面使用jstl标签</span><span style="color: #008000">--></span>
<span style="color: #0000ff"><</span><span style="color: #800000">dependency</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">groupId</span><span style="color: #0000ff">></span>javax.servlet<span style="color: #0000ff"></</span><span style="color: #800000">groupId</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">artifactId</span><span style="color: #0000ff">></span>jstl<span style="color: #0000ff"></</span><span style="color: #800000">artifactId</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"></</span><span style="color: #800000">dependency</span><span style="color: #0000ff">></span> <span style="color: #008000"><!--</span><span style="color: #008000">用于编译jsp</span><span style="color: #008000">--></span>
<span style="color: #0000ff"><</span><span style="color: #800000">dependency</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">groupId</span><span style="color: #0000ff">></span>org.apache.tomcat.embed<span style="color: #0000ff"></</span><span style="color: #800000">groupId</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">artifactId</span><span style="color: #0000ff">></span>tomcat-embed-jasper<span style="color: #0000ff"></</span><span style="color: #800000">artifactId</span><span style="color: #0000ff">></span>
<span style="color: #008000"><!--</span><span style="color: #008000"><scope>provided</scope></span><span style="color: #008000">--></span>
<span style="color: #0000ff"></</span><span style="color: #800000">dependency</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">dependency</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">groupId</span><span style="color: #0000ff">></span>org.springframework.boot<span style="color: #0000ff"></</span><span style="color: #800000">groupId</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">artifactId</span><span style="color: #0000ff">></span>spring-boot-starter-test<span style="color: #0000ff"></</span><span style="color: #800000">artifactId</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">scope</span><span style="color: #0000ff">></span>test<span style="color: #0000ff"></</span><span style="color: #800000">scope</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"></</span><span style="color: #800000">dependency</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"></</span><span style="color: #800000">dependencies</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">build</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">plugins</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">plugin</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">groupId</span><span style="color: #0000ff">></span>org.springframework.boot<span style="color: #0000ff"></</span><span style="color: #800000">groupId</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">artifactId</span><span style="color: #0000ff">></span>spring-boot-maven-plugin<span style="color: #0000ff"></</span><span style="color: #800000">artifactId</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"></</span><span style="color: #800000">plugin</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"></</span><span style="color: #800000">plugins</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"><</span><span style="color: #800000">finalName</span><span style="color: #0000ff">></span>firstDemo<span style="color: #0000ff"></</span><span style="color: #800000">finalName</span><span style="color: #0000ff">></span>
<span style="color: #0000ff"></</span><span style="color: #800000">build</span><span style="color: #0000ff">></span>
</project>
好了 这两步完成,就可以按照上面的打包过程,打包为war包,然后放在外部的tomcat下,start.bat就可以访问了。
========================================================================================================================================
最后 启动起来外部的tomcat ,在浏览器中访问路径如下:
需要加上你的项目名字,才能成功访问。也就是这个文件夹的名字。
好了,到这里为止,终于能将一个springboot项目成功的打包并且放在外部的tomcat下启动并且能够成功访问到页面了。
========================================================================================================================
最后的最后,你是否注意到pom.xml文件中 ,上一个章节到这一章节一直在纠结的一个问题:
到现在为止,已经剔除了内置的tomcat的情况下
如果指定scope范围为provided的话
那么
1.启动类启动项目的情况下:
<scope>provided</scope>添加的情况,不能成功启动,项目不能访问
不添加的情况,使用默认的scope,可以成功启动,项目可以访问
访问地址:http://localhost:8080/view/hello
2.在右侧spring-boot:run启动的情况下:
<scope>provided</scope>添加的情况,可以成功启动,项目可以访问
不添加的情况,使用默认的scope,可以成功启动,项目可以访问
访问地址:http://localhost:8080/view/hello
3.在命令行启动打包的war包情况下:
<scope>provided</scope>添加的情况,可以成功启动,项目可以访问
不添加的情况,使用默认的scope,可以成功启动,项目可以访问
访问地址:http://localhost:8080/view/hello
4.将war包部署在外部tomcat下运行的情况下:
<scope>provided</scope>添加的情况,可以成功启动,项目可以访问
不添加的情况,使用默认的scope,可以成功启动,项目可以访问
访问地址:http://localhost:8080/firstDemo/view/hello
第一种启动方式:
第二种启动方式:
第三种启动方式:
第四种启动方式:
idea下springboot打包成jar包和war包,并且可以在外部tomcat下运行访问到的更多相关文章
- 【spring boot】idea下springboot打包成jar包和war包,并且可以在外部tomcat下运行访问到(转)
转自:https://www.cnblogs.com/sxdcgaq8080/p/7727249.html 接着上一章走呗:http://www.cnblogs.com/sxdcgaq8080/p ...
- 【spring boot】6.idea下springboot打包成jar包和war包,并且可以在外部tomcat下运行访问到
接着上一章走呗:http://www.cnblogs.com/sxdcgaq8080/p/7712874.html 然后声明一点,下面打包的过程中,scope一直都是使用默认的范围 <!--用于 ...
- springboot打包成jar包后找不到xml,找不到主类的解决方法
springboot打包成jar包后找不到xml,找不到主类的解决方法 请首先保证你的项目能正常运行(即不打包的时候运行无误),我们在打包时经常遇到如下问题: springboot打包成jar包后找不 ...
- Springboot打包成jar包形式发布
1.修改配置文件pom.xml 添加打包形式设置为jar形式 <packaging>jar</packaging> 2.在build标签内添加内容如下 finalname为打包 ...
- 第三篇 -- SpringBoot打包成jar包
本篇介绍怎么将SprintBoot项目打包成jar包. 第一步:点击IDEA右侧的maven. 第二步:双击package,然后就会开始打包,当出现build success时,就打包成功了,一般在t ...
- idea将springboot打包成jar或者war
1.首先在pom.xml中添加下面配置 <groupId>com.melo</groupId> <artifactId>focus</artifactId&g ...
- springboot打包成jar文件无法正常运行,解决办法已经找到
1.用intellij idea 创建了一个springboot的项目,前期都运行的好好的,在ide中可以正常运行,但是打包成Jar运行却一直报错. 2.经过不懈探索,终于找到解决办法 3.首先,找到 ...
- Maven打包成Jar文件时依赖包的问题
我们项目中使用到第三方的库文件,这些jar库文件并没有放到Maven中央库上,导致我们需要在项目中自己配置使用.我们的两三个开发人员对Java都是很熟,因此在使用中遇到了一些问题,表现在:在本地中引入 ...
- springboot 打包成jar
1.pom.xml配置 <build> <plugins> <plugin> <groupId>org.apache.maven.plugins< ...
随机推荐
- iosopendev配置
Permission denied, please try again.Permission denied, please try again.Permission denied (publickey ...
- 聊聊C语言和ABAP
这个公众号之前的文章,分享的都是Jerry和SAP成都研究院的同事在工作中学到的一些知识和感受.而今天这篇文章,写作的由来是因为最近我又参与了SAP成都数字创新空间应聘者的面试,和一些朋友聊了一些关于 ...
- UVA 1625 Color Length 颜色的长度 (预处理+dp)
dp[i][j]表示前一个序列拿了i个颜色,后一个序列拿了j个颜色的最小花费. 转移的时候显然只能向dp[i+1][j],或dp[i][j+1]转移,每增加拿走一个颜色,之前已经出现但没结束的颜色个数 ...
- python 判断路径是否存在
import os os.path.exists(文件绝对路径)
- mac 上node.js环境的安装与测试【转】
http://blog.csdn.net/baihuaxiu123/article/details/51868142 一 摘要 如何大家之前做过web服务器的人都知道,nginx+lua与现在流行的n ...
- 数据库:SQL Server自增长列的编号
SQL Server表中的自动编号ID重新开始排列 说法一: 有两种方法: 方法1: truncate table 你的表名 --这样不但将数据删除,而且可以重新置位identity属性的字段. 方法 ...
- PAT (Basic Level) Practise (中文)-1035. 插入与归并(25)
PAT (Basic Level) Practise (中文)-1035. 插入与归并(25) http://www.patest.cn/contests/pat-b-practise/1035 ...
- 两种常见JS面向象写法
基于构造函数 function Circle(r) { this.r = r; } Circle.PI = 3.14159; Circle.prototype.area = function() { ...
- 洛谷 P2846 光开关
https://www.luogu.org/problemnew/show/P2846 好多题解用线段树来写,然而分块不是更简单好些吗? 一个数组use记录这一块进行了多少次开关操作,两边单独计算,注 ...
- UVa-10474-大理石在哪
lower_bound()的作用是查找"大于或等于x的第一个位置",但是返回的是地址,所以减去数组的首地址就是偏移量了,也就是整型数字. #include <iostream ...