春ブーツは、別々のTomcatを実行するためのプロジェクトを展開します

1、のpom.xml

<プロジェクトの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.00 </ modelVersion> 
  <のgroupId> com.shunneng.springboot </のgroupId> 
  <たartifactId> springboot-DEMO2 </たartifactId> 
  <バージョン> 0.01 -snapshot </バージョン> 
  <パッケージ>戦争</梱包> 
 <親> 
    <groupIdを>組織。 
    <たartifactId>2.01 .RELEASE </バージョン> 
</親> 
<依存性> 
    <依存性> 
        <のgroupId> org.springframework.boot </のgroupId> 
        <たartifactId>ばねブートスタータウェブ</たartifactId> 
    </依存> 
    <依存性> 
            <のgroupId> org.springframework.boot </のgroupId> 
            <たartifactId>ばねブートスタータTomcatの</たartifactId> 
            <スコープ>提供</スコープ> 
    </依存> 
</依存関係> 
</プロジェクト>

2、SpringBootServletInitializerを継承するクラスのニーズを開始

輸入org.springframework.boot.SpringApplication。
輸入org.springframework.boot.autoconfigure.SpringBootApplication。
輸入org.springframework.boot.builder.SpringApplicationBuilder。
輸入org.springframework.boot.web.servlet.support.SpringBootServletInitializer。
輸入org.springframework.stereotype.Controller。
輸入org.springframework.web.bind.annotation.RequestMapping。
輸入org.springframework.web.bind.annotation.ResponseBody。


@SpringBootApplication 
@Controller 
パブリック クラスHelloSpringBootはSpringBootServletInitializer {延び

    @RequestMapping(" /ハロー" 
    @ResponseBody 
    公開ハロー文字列(){
         戻り " ハローspringboot " ; 
    } 


    @Overrideは
    保護SpringApplicationBuilder設定(SpringApplicationBuilderビルダ){
         戻り builder.sources(HelloSpringBoot クラス); 
    } 


    / * * 
     * springboot実行エントリ
     * / 
    パブリック 静的 ボイドメイン(文字列[]引数){
         // SpringApplication.run(HelloSpringBoot.class、引数); // 追加のプロモーターは、代わりにこのラインを設けて使用することはできません 
        = SpringApplicationファイルアプリケーション新しい新。SpringApplication(HelloSpringBootのクラス);
//         application.setBannerMode(Mode.OFF)。// 关闭バナー
        application.run(引数); 
    } 
}

 

おすすめ

転載: www.cnblogs.com/xiaofengfree/p/11420938.html
おすすめ