<small id='PCxFN'></small> <noframes id='Sgwl'>

  • <tfoot id='EiKLplQv'></tfoot>

      <legend id='TlCdHOL'><style id='2hRND4CH'><dir id='Hc9mbt7yl'><q id='Yu6oZR7'></q></dir></style></legend>
      <i id='OpjM7'><tr id='qpWPAwH1t9'><dt id='ISGcf4wXv'><q id='uBb9nQ5'><span id='5wHJ2qnZus'><b id='dqQ6I'><form id='WJoMPUjQ'><ins id='kVucoiXyN'></ins><ul id='7iJmc6aN'></ul><sub id='hmCQM'></sub></form><legend id='Xd6qsz'></legend><bdo id='b4Wex'><pre id='RA61M0C2G'><center id='YM18'></center></pre></bdo></b><th id='EjvkVCIpsn'></th></span></q></dt></tr></i><div id='NbKHemj'><tfoot id='T3U2A5lpm'></tfoot><dl id='D6RN'><fieldset id='3GL8r'></fieldset></dl></div>

          <bdo id='RWaj'></bdo><ul id='i4TS'></ul>

          1. <li id='xiqdCEn1At'></li>
            登陆

            1号站平台官网注册码-修正Jar包为War包

            admin 2019-12-15 155人围观 ,发现0个评论

            一、修正pom.xml文件将默许的jar办法改为war:

            com.example

            application

            0.0.1-SNAPSHOT

            war

            二、扫除内置的Tomcat容器(两种办法都可):

            1.扫除spring-boot-starter-web中的Tomcat

            org.springframework.boot

            spring-boot-starter-web

            org.springframework.boot

            spring-boot-starter-tomcat

            2.增加依靠

            org.springframework.boot

            spring-boot-starter-tomcat

            provided

            三、承继org.sp急性胃炎ringframework.boot.web.servlet.support.SpringBootServletInitializer,完成configure办法:

            为什么承继该类,SpringBootSer1号站平台官网注册码-修正Jar包为War包vletInitializer源码注释:

            Not1号站平台官网注册码-修正Jar包为War包e that a WebApplicationInitializer is only needed if you are building a war file and deploying it.

            If you prefer to run an embedded web server then you won't need this at all.

            留意,假如您正在构建WAR文件并布置它,则需求WebApplicationInitializer。

            假如你喜爱运转一个嵌入式Web服务器,那么你底子不需求这个。

            发动类代码:

            @Spr1号站平台官网注册码-修正Jar包为War包ingBootApplication

            public class Application {

            public static void main(String[] args) {

            SpringApplication.run(Application.class, args);

            }

            }

            1.办法一,发动类承继SpringBootServletInitializer完成configure:

            @SpringBootApplication

            public class Application extends SpringBootServletInitializer {

            public static void main(String[] args) {

            SpringApplication.run(Application.class, args);

            }

            @Override

            protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {

            return builder.sources(Application.class);

            }

            }

            2.办法二,新增加一个类承继SpringBootServletInitializer完成configure:

            public class ServletInitializer extends SpringBootServletInitializer {

            @Override

            protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {

            //此处的Application.class为带有@SpringBootApplication注解的发动类

            return builder.sources(Application.class);

            }

            }

            留意事项:

            运用外部Tomcat布置拜访的时分,application.properties(或许application.yml)中装备的

            server.port=

            server.servlet.context-path=

            将失效,请运用tomcat的端口,tomcat,webapps下项目名进行拜访。

            为了避免运用上下文所导致的项目拜访资源加载不到的问题,

            主张pom.xml文件中标签下增加标签:

            war包称号

            org.springframework.boot

            spring-boot-maven-plugin

            运用mvn命令行打包,运转:

            clean是铲除之前的包,-Dmaven.test.skip=true是疏忽测验代码

            jar 办法打包,运用内置Tomcat:mvn clean install -Dmaven.test.skip=true

            运转:java -jar 包名.jar

            war办法打包,运用外置Tomcat:mvn clean package -Dmaven.test.skip=true

            运转:${Tomcat_home}/bin/目录下履行startup.bat(windows)或许startup.sh(linux)

            请关注微信公众号
            微信二维码
            不容错过
            Powered By Z-BlogPHP