69 lines
8.5 KiB
HTML
69 lines
8.5 KiB
HTML
<p>1:修改pom.xml</p>
|
||
<p>将“jar”改为“war”</p>
|
||
<div class="cnblogs_code">
|
||
<pre> <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></pre>
|
||
</div>
|
||
<p> </p>
|
||
<p>将:</p>
|
||
<div class="cnblogs_code">
|
||
<pre> <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></pre>
|
||
</div>
|
||
<p>修改为:</p>
|
||
<div class="cnblogs_code">
|
||
<pre> <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: #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: #008000;"><!--</span><span style="color: #008000;">打包的时候可以不用包进去,别的设施会提供。事实上该依赖理论上可以参与编译,测试,运行等周期。
|
||
相当于compile,但是打包阶段做了exclude操作</span><span style="color: #008000;">--></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></pre>
|
||
</div>
|
||
<p> </p>
|
||
<p>修改build节点下的<plugin>将:</p>
|
||
<div class="cnblogs_code">
|
||
<pre> <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></pre>
|
||
</div>
|
||
<p>改为:</p>
|
||
<div class="cnblogs_code">
|
||
<pre> <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;">configuration</span><span style="color: #0000ff;">></span>
|
||
<span style="color: #008000;"><!--</span><span style="color: #008000;"> 发布linux服务包,直接用linux的servic命令启动 </span><span style="color: #008000;">--></span>
|
||
<span style="color: #0000ff;"><</span><span style="color: #800000;">executable</span><span style="color: #0000ff;">></span>true<span style="color: #0000ff;"></</span><span style="color: #800000;">executable</span><span style="color: #0000ff;">></span>
|
||
<span style="color: #0000ff;"></</span><span style="color: #800000;">configuration</span><span style="color: #0000ff;">></span>
|
||
<span style="color: #0000ff;"></</span><span style="color: #800000;">plugin</span><span style="color: #0000ff;">></span></pre>
|
||
</div>
|
||
<p> </p>
|
||
<p>2:修改启动类:</p>
|
||
<div class="cnblogs_code">
|
||
<pre><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> Application <span style="color: #0000ff;">extends</span><span style="color: #000000;"> SpringBootServletInitializer{
|
||
|
||
</span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> main(String[] args) {
|
||
SpringApplication.run(Application.</span><span style="color: #0000ff;">class</span><span style="color: #000000;">, args);
|
||
}
|
||
|
||
@Override
|
||
</span><span style="color: #0000ff;">protected</span><span style="color: #000000;"> SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
|
||
</span><span style="color: #008000;">//</span><span style="color: #008000;"> 注意这里要指向原先用main方法执行的Application启动类</span>
|
||
<span style="color: #0000ff;">return</span> builder.sources(Application.<span style="color: #0000ff;">class</span><span style="color: #000000;">);
|
||
}
|
||
}</span></pre>
|
||
</div>
|
||
<p> </p> |