<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ## 一、修改打包方式 ~~~ <packaging>war</packaging> ~~~ 將上面的代碼加入到pom.xml文件剛開始的位置,如下: ![](https://img.kancloud.cn/bc/5d/bc5ddb27464052b7895786c2fd04ddde_678x274.png) ## 二、 排除內置tomcat的依賴 我們使用外置的tomcat,自然要將內置的嵌入式tomcat的相關jar排除。 ~~~ <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> ~~~ 接上節,去掉undertow ![](https://img.kancloud.cn/0d/59/0d598557fe070dfcbc810a1ef27847cf_932x515.png) 因為去掉所有server依賴后程序里的servlet無法找到對應的依賴包,所以需要我們自己引入一個servlet依賴。 ~~~ <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>4.0.1</version> </dependency> ~~~ mybatis因為是配置在pom中,利用pom導出war包會導致逆向重寫mapper,所以這段需要注釋掉。 ~~~ <!--<plugin> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-maven-plugin</artifactId> <version>1.3.7</version> <configuration> &lt;!&ndash; generator 工具配置文件的位置 &ndash;&gt; <configurationFile>src/main/resources/mybatis-generator/generatorConfig.xml</configurationFile> <verbose>true</verbose> &lt;!&ndash; 是否覆蓋 &ndash;&gt; &lt;!&ndash; 此處要特別注意,如果不加這個設置會導致每次運行都會在原目錄再次創建&ndash;&gt; <overwrite>true</overwrite> </configuration> <executions> <execution> <id>Generate MyBatis Artifacts</id> <goals> <goal>generate</goal> </goals> </execution> </executions> <dependencies> <dependency> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-core</artifactId> <version>1.3.7</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.46</version> </dependency> </dependencies> </plugin>--> ~~~ ![](https://img.kancloud.cn/96/11/961196783d9cd9be7672733042996888_905x733.png) ## 三、新增加一個類繼承SpringBootServletInitializer實現configure: 為什么繼承該類,SpringBootServletInitializer源碼注釋: Note 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服務器,那么你根本不需要這個。 ~~~ public class ServletInitializer extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { //此處的Application.class為帶有@SpringBootApplication注解的啟動類 return builder.sources(BootLauchApplication.class); } } ~~~ ## 四、build要有finalName標簽 pom.xml中的構建build代碼段,要有應用最終構建打包的名稱。 ~~~ <finalName>boot-lauch</finalName> ~~~ ![](https://img.kancloud.cn/99/49/994918d83e410e564449d6f336bbcafc_809x206.png) ## 五、打包與運行 先clean把編譯內容清空一下 ![](https://img.kancloud.cn/cb/61/cb614b7963e160887e4702f504add123_624x604.png) war方式打包,打包結果將存儲在項目的target目錄下面。然后將war包部署到外置Tomcat上面: ![](https://img.kancloud.cn/0e/e6/0ee68f1497aa67e688ebd4bc4fdd4743_739x478.png) 輸入內容如下,含義是不打包test,依據pom.xml來進行打包 ~~~ package -Dmaven.test.skip=true -f pom.xml ~~~ ![](https://img.kancloud.cn/7c/de/7cde78e5b92f784c3269d73bb40d981d_1715x1028.png) ![](https://img.kancloud.cn/ac/ed/aced3d2f4127abf6a2fde3f9b0a95af7_637x244.png) ![](https://img.kancloud.cn/42/3f/423f08831644fe14b7d0eeab22c1a12d_622x436.png) ![](https://img.kancloud.cn/64/d9/64d945783d3c6516c44a521d8826247f_613x837.png) ![](https://img.kancloud.cn/db/a8/dba883416baf41f1f0dea2e59510d237_1318x520.png) 在外置tomcat中運行:${Tomcat\_home}/bin/目錄下執行startup.bat(windows)[或者startup.sh](http://xn--startup-gf7nh96s.sh/)(linux),然后通過瀏覽器訪問應用,測試效果。 ![](https://img.kancloud.cn/5e/c6/5ec6c7121b89fcee8cd4e90a8cde6296_965x376.png) ![](https://img.kancloud.cn/e8/f4/e8f4126a45e2bb6ad56d12909c7d23af_955x707.png) ![](https://img.kancloud.cn/91/ad/91ad39f661c873c971197d1a5dc54cc4_1139x597.png) > 注意事項: > 使用外部Tomcat部署訪問的時候,application.properties(或者application.yml)中的如下配置將失效,請使用外置的tomcat的端口,tomcat的webapps下項目名進行訪問。 [http://127.0.0.1:8080/boot-lauch/template/thymeleaf](http://127.0.0.1:8080/boot-lauch/template/thymeleaf) ![](https://img.kancloud.cn/c1/69/c169ec911c2075f91cbc1b9a1f57c539_1251x734.png) ## 踩坑 1、之前的ArticleVO和mapper中ID格式不一樣會報錯,.intValue() 轉義后可以正常打war包。 ![](https://img.kancloud.cn/95/18/9518b5304c3e5fb0f43972e2bb13698c_602x166.png) 2、如果mybatis是利用pom.xml文件逆向自動生成的,則在maven打war包時會逆向重新編譯mapper文件導致服務報錯無法啟動,所以需要修改pom.xml注釋掉逆向部分。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看