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< ...
随机推荐
- 使用javap分析Java的字符串操作
我们看这样一行简单的字符串赋值操作的Java代码. String a = "i042416"; 使用命令行将包含了这行代码的Java类反编译查看其字节码: javap -v con ...
- 说说三四月的app审核中的几个坑
苹果的审核在3月异常严格,听说和换了部门领导有关(道听途说),恰逢三月公司新出了一个产品,我们的产品被苹果打回四五次,今天就在简书上把这些坑填下,也让遇到的朋友以后留意,也许是近期的最后一篇文章. 坑 ...
- C#反射调用小DEMO
程序集的源代码: namespace DesignMode { class IOCTest { public void TestO() { Console.WriteLine("O方法&qu ...
- CSS声明各个浏览器私有属性的命名前缀
-moz代表firefox浏览器私有属性-ms代表IE浏览器私有属性-webkit代表chrome.safari私有属性-o代表opera私有属性
- HDOJ4550 卡片游戏 随便销毁内存的代价就是wa//string类的一些用法
思路 标记最小的最后的位置 放在第一位 标记位置之前按left值小的左方大的右方 标记位置之后按顺序放在最后 不多说先贴上销毁内存的wa代码 销毁内存的wa代码 #include<cstdio ...
- django 2.0 + pycharm2017 出现的问题
在创建完成app之后,在models文件里创建两个类:BlogType , Blog, 创建超级用户,注册admin,在登陆admin之后发现,发现 BlogType , Blog,并没有导入到adm ...
- Hopfield 网络(下)
讲的什么 这部分主要讲离散的 Hopfield 网络权值的计算方法,以及网络记忆容量.主要参考了网上搜到的一些相关 PPT. DHNN 的训练方法 常见的学习方法中有海布法,还有 \(\delta ...
- 电脑上文件的后缀名被隐藏,把一个文本文件改成.bat时,默认打开的还是文本。
1.打开文件夹,选择组织,点击“文件夹和搜索选项”,如图: 2.选择“查看”,找到“隐藏已知文件类型的扩展名”,不要勾选这一项,如图: 3.点击“确定”或者“应用”
- PDO drivers no value 解决办法
我的服务器是windos系统的,而且我也已经开启了PDO扩展,但是查看phpinfo的时候,结果却如下图: 解决办法 修改 php.ini 中的 extension_dir 路径即可! 将extens ...
- bootstrap table 保留翻页选中数据
$(function () { $('#exampleTable').on('uncheck.bs.table check.bs.table check-all.bs.table uncheck-al ...