スプリングブートとは何ですか
Spring Bootは、Pivotalチームが提供する新しいフレームワークです。新しいスプリングアプリケーションの初期建設および開発プロセスを簡素化するように設計されています。フレームワークは特定の方法を使用して構成するため、開発者はボイラープレート構成を定義する必要がなくなります。
スプリングブート機能
開発手順
Mavenプロジェクトを作成します
pom.xmlファイル構成
依存関係を追加します
<?xml version = "1.0" encoding = "utf-8"?> <project xmlns = "http://maven.apache.org/pom/4.0.0" xmlns:xsi = "http://www.w3.org/2001/xmlschema-instance <http://www.w3.org/2001 xsi:schemalocation = "http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.0.sdsd"> <modeleversion> 4.0.0 </modelversion> <グループ<バージョン> 0.0.1-snapshot </version> <packaging> jar </packaging> <name> springboot </name> <description> spring boot </description> <parent> <priplingframework.boot </groupid> <artifactid> spring-boot-starter- version </artifactid> </> </> <! - リポジトリからのlookup parent-> </parent> <properties> <properties> <project.build.sourceencoding> utf-8 </project.build.sourceencoding> <project.outputencoding> utf-8 </project.reporting.outputencodin <Dependencies> <Dependency> <groupId> org.springframework.boot </groupid> <artifactid> spring-boot-starter-web </artifactid> </dependency> <dependency> <groupid> org.springframework.boot </groupid> <artifactid> </scope> </scope> </scortid> </dependency> </dependencies> <burtion> <plugins> <groupid> org.springframework.boot </groupid> <artifactid> spring-boot-maven-plugin </artifactid> </plugin> </plugins> </build> </project>
パッケージcom.tl.app; Import org.springframework.boot.springApplication; Import org.springframework.boot.autoconfigure.enableautoconfiguration; import org.springframework.context.annotation.componentscan;@enableautoconfiguration@[email protected](basonentcan(basonentcan) class appstart {public static void main(string [] args){springApplication.run(appstart.class、args); }}
コントローラーを作成します
パッケージcom.tl.app; Import java.util.hashmap; import java.util.map; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.responsebody;@org.springframework。 @RequestMapping( "/index")@responsebody public map <string、string> index(){map map = new hashmap <string、string>(); map.put( "wukong"、 "is monkey"); map.put( "lu ban"、 "is a hero");マップを返します。 }}エントリ関数を実行します
Tomcatが開始されました、ポート8080
アクセスコントローラー
要約します
上記は、編集者が紹介したスプリングブートおよび環境構築プロセスです。それがあなたに役立つことを願っています。ご質問がある場合は、メッセージを残してください。編集者は時間内に返信します。 wulin.comのウェブサイトへのご支援ありがとうございます!