Springboot_エントリーのHelloWorld

ターゲット:入力します。http:// localhostを:8080 /こんにちは、GETのHelloWorld

 

hello.java

パッケージ、クラス、

インポートorg.springframework.boot.SpringApplication;
 インポートorg.springframework.boot.autoconfigure.SpringBootApplication; 

/ * 
メインクラスがorg.apache.tomcat.embed解決できない@SpringBootApplicationの注釈:Tomcatの-埋め込む -core:8.5 0.20 
、アプリケーションがSpringBootであることを示す
参照、オープン@SpringBootApplication:
@Target(ElementType.TYPE {})
@Retention(RetentionPolicy.RUNTIME)
@Documented 
@Inherited 
@SpringBootConfiguration 
@EnableAutoConfiguration 
@ComponentScan(
    excludeFilters @Filter = {(
    = FilterType.CUSTOMタイプ、
    クラスTypeExcludeFilter.class} = { 
)、@Filter(
    タイプ= FilterType.CUSTOM、
    } = {AutoConfigurationExcludeFilter.classクラス
)} 
パブリック@interfaceのSpringBootApplication { 

@SpringBootConfiguration:--- SpringBoot構成クラスプロファイルコンフィギュレーションクラス容器アセンブリである
オープン自動設定:@EnableAutoConfiguration 
      @AutoConfigurationPackage:マスター設定パケットベースの自動すべてのコンポーネントおよびスキャンスプリング容器内の次のサブパケットのすべての
            @import({Registrar.class})容器に導入スプリングボトムノートは、アセンブリRegistrar.class} { 
      成分が導入された@import(AutoConfigurationImportSelector.class {})選択はの完全修飾クラス名様に必要なすべてのコンポーネントを返します。
      これらのコンポーネントは、コンテナ、輸入部品の多くに追加されます自動的に構成し、クラス、インポートコンテナ、このシナリオに必要なすべてのコンポーネント、および設定することですこれらのコンポーネントは
      自動設定クラスを持って、それは私たちが手作業などの機能部品の準備に入った仕事を設定する必要性がなくなり

      、全体的なJ2EE統合ソリューションと自動設定をスプリング・ブート自動構成-2.0.0.RELEASE.jarです
 * / 
@ SpringBootApplication
パブリック クラス{ハロー
     パブリック 静的 ボイドメイン(文字列[]引数){
         // Springアプリケーション起動 
        SpringApplication.run(こんにちは。クラス、引数を); 
    } 
}

 

helloController.java

パッケージClass.Controlを。
輸入org.springframework.stereotype.Controller;
輸入org.springframework.web.bind.annotation.RequestMapping。
輸入org.springframework.web.bind.annotation.ResponseBody。

@Controller 
パブリック クラスhelloController { 
    @ResponseBody 
    @RequestMapping( "/ハロー" パブリック文字列H(){
         リターン "HelloWorldの" ; 
    } 
}

 

pom.xml

< > 
        < groupIdを> org.springframework.boot </ groupIdを> 
        < たartifactId >春・ブート・スターター・親</ たartifactId > 
        < バージョン> 2.0.0.RELEASE </ バージョン> 
    </ > 
    <! - 上述代码的父项目是
      <親> 
      <groupIdを> org.springframework.boot </ groupIdを> 
      <たartifactId>春ブート依存関係</たartifactId> 
      <バージョン> 2.0.0.RELEASE </バージョン> 
      <relativePath> ../ 。../ springboot-依存関係</ relativePath> /春ブート依存関係</ relativePath> 
  </親>
  springbootバージョン仲裁センター: 
  私たちは、依存性はデフォルトのバージョン(依存関係の管理を依存している自然バージョン番号を宣言する必要はありません)書く必要はありませんインポートした後

  springboot-スターター・ウェブ:私たちは、コンポーネント、Webモジュールをインポートするヘルプが正常に動作している依存
  spring-をブート・スターター:springbootシーンイニシエータ

  springboot全てのシーンが抽出された特徴は、スターター(始動)で作られた1は、スターター内のアイテムを紹介するために、これらの唯一の必要性が
  導入されたすべての関連するシーンが依存する、使用どのような機能がスターターに導入されているもののシーン
  - > 

    < 依存> 
        < 依存> 
            < groupIdを> org.springframework.boot </ groupIdを> 
            < たartifactId >春ブーツ・スターター・ウェブ</ たartifactId > 
        </ 依存関係> 
    </ 依存関係> 

    <!- このプラグは、パケットジャーを適用する実行可能ファイルにパッケージ化することができる- > 
    < ビルド> 
        < プラグイン> 
            < プラグイン> 
                < groupIdを> org.springframework.boot </ groupIdを> 
                < たartifactId >春・ブートのmaven-pluginの</ たartifactId > 
                < バージョン> 2.0.0.RELEASE </ バージョン> 
            </ プラグイン> 
        </ プラグイン> 
    </ ビルド> 
</ プロジェクト>

 

おすすめ

転載: www.cnblogs.com/zuiaimiusi/p/12453243.html