まず、準備作業:
環境とツール:Eclipseの+ JDK8 + Mavenの+ SpringBoot
第二に、ソースコード:
1.プロジェクトのフレームワーク:
2.はじめの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/maven-v4_0_0.xsd "> <modelVersion> 4.0.0 </ modelVersion> <groupIdを>ブログウェブ</ groupIdを> <たartifactId>ブログウェブ</たartifactId> <パッケージ>戦争</梱包> <バージョン> 0.0.1-SNAPSHOT </バージョン> <名前>ブログ・ウェブのMavenのWebapp </名前> <URL>のhttp:// 達人。 apache.org </ URL> <! -父级项目- > <親> <groupIdを> org.springframework.boot </ groupIdを> <たartifactId> </親>春・ブート・スターター・親</たartifactId> <バージョン> 2.1.0.RELEASE </バージョン> <relativePath /> <! -リポジトリからのルックアップの親- > <依存性> <! -测试- > <依存> <groupIdを> org.springframework.boot </ groupIdを> <たartifactId>春・ブートstarter-テスト</たartifactId> <スコープ>テスト</スコープ> </依存関係> <! - springmvc - > <依存> <groupIdを> org.springframework.boot </ groupIdを> <たartifactId>春・ブート・スターター・ウェブ</たartifactId> </依存関係> <! - JPA(持久层) - > <依存> <groupIdを> org.springframework.boot </ groupIdを> <たartifactId>春・ブート・スターター・データ-JPA </たartifactId> </依存関係> <! - HTTPS:// mvnrepository.com/artifact/javax.servlet/javax.servlet-api - > <依存性> <groupIdを>のjavax.servlet </のgroupId> <たartifactId>のjavax.servlet-API </たartifactId> <スコープ>提供< /スコープ> </依存関係> < -のhttps:// mvnrepository.com/artifact/commons-fileupload/commons-fileupload - > <依存> <groupIdを>コモンズ-ファイルアップロード</ groupIdを> <たartifactId>コモンズ、ファイルアップロード</たartifactId> <バージョン> 1.3 </ version>の </依存関係> < -のhttps:// mvnrepository.com/artifact/commons-io/commons-io - > <依存> <groupIdを>コモンズ-IO </ groupIdを> <たartifactId>コモンズ-IO </たartifactId> <設定> <バージョン> 2.6 </ version>の </依存関係> < -のhttps:// mvnrepository.com/artifact/org.codehaus.jackson/jackson-core-asl - > <依存> <groupIdを> org.codehaus。ジャクソン</ groupIdを> <たartifactId>ジャクソン・コア-ASL </たartifactId> <バージョン> 1.9.13 </バージョン> </依存関係> </依存関係> <! -编译- > <ビルド> <! -插件- > <プラグイン> <! - Mavenの插件- > <プラグイン> <groupIdを> org.springframework.boot </ groupIdを> <たartifactId>春・ブートのmaven-pluginの</たartifactId> <ソース> 1.8 </ソース> <ターゲット> 1.8 </標的> <エンコーディング> UTF-8 </エンコーディング> </ configuration>の </プラグイン> </プラグイン> </構築> </プロジェクト>
3.スタートクラス
パッケージコム;
輸入org.springframework.boot.SpringApplication。
輸入org.springframework.boot.autoconfigure.SpringBootApplication。
輸入org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration。
輸入org.springframework.context.annotation.ComponentScan;
//扫描的包
@ComponentScan(basePackages = "com.controller")
@SpringBootApplication(=除外{DataSourceAutoConfiguration.class})
パブリッククラスBlogStarter {
パブリック静的無効メイン(文字列[] args){
SpringApplication.run(BlogStarter.class、引数);
}
}