スプリングガイド-起動/コアライブラリ/構築方法
5319 ワード
いちじしどうばね
📖 ✏️
@SpringBootApplication
public class HelloSpringApplication {
public static void main(String[] args) {
SpringApplication.run(HelloSpringApplication.class, args);
}
}
main()が最初に運転され、SpringApplication.run()
のパラメータクラスが運転を開始し、スプリングガイドが運転を開始します.@SpringBootApplication
が宣言されたため、スプリング起動アプリケーションが実行されます.カーネルTomcat Webサーバが独自に動作すると、スプリングガイドが実行されます.
スプリングガイドのコアライブラリ
SpringBootには多くの異なるライブラリがあり、それらの間には異なる段階の依存関係があります.
スプリングガイドは依存性を自動的に管理するため、必要なすべてのライブラリを自動的にインポートします.
スプリングガイドのコアライブラリを以下に示します.
-spring-boot-start-tomcat:Tomcat(Webサーバ)
-spring-webmvc:springWeb MVC
- spring-boot
- spring-core
- spring-boot-starter-logging logback, slf4j
スプリングガイドが「ホーム」(Welcome Page)を検索する方法
7.1.6. Welcome Page
Spring Boot supports both static and templated welcome pages. It first looks for an index.html file in the configured static content locations. If one is not found, it then looks for an indext template. If either is found, it is automatically used as the welcome page of the application.
ソース:https://docs.spring.io/spring-boot/docs/2.3.1.RELEASE/reference/html/spring-boot-features.html#boot-features-spring-mvc-welcome-page
画像の出所:金英漢<スプリング入門-コード学習のスプリング起動、Web MVC、DBアクセス技術>課程資料
index.htmlでコントローラに移動すると、viewResolverは値を返して画面を検索します.
Spring BootテンプレートエンジンはviewNameマッピングをサポートします.
スプリングガイドの構築と実行
java -jar (파일명).jar
を入れて実行するだけです. woply@Jaeminui-MacBookPro ~/study/hello-spring master ll
total 48
-rw-r--r--@ 1 woply staff 1.4K 1 5 06:47 HELP.md
drwxr-xr-x 6 woply staff 192B 1 5 16:32 build
-rw-r--r--@ 1 woply staff 498B 1 5 06:47 build.gradle
drwxr-xr-x@ 3 woply staff 96B 1 5 06:47 gradle
-rwxr-xr-x@ 1 woply staff 7.9K 1 5 06:47 gradlew
-rw-r--r--@ 1 woply staff 2.7K 1 5 06:47 gradlew.bat
drwxr-xr-x 3 woply staff 96B 1 5 16:58 out
-rw-r--r--@ 1 woply staff 34B 1 5 06:47 settings.gradle
drwxr-xr-x@ 4 woply staff 128B 1 5 06:47 src
✘ woply@Jaeminui-MacBookPro ~/study/hello-spring master ./gradlew build
woply@Jaeminui-MacBookPro ~/study/hello-spring master cd build
woply@Jaeminui-MacBookPro ~/study/hello-spring/build master cd libs
woply@Jaeminui-MacBookPro ~/study/hello-spring/build/libs master java -jar hello-spring-0.0.1-SNAPSHOT.jar
ビルドフォルダを削除するとき./gradlewcleanを実行します.既存のコンストラクションファイルを完全に消去して再構築する場合./gradle clean buildを実行します.
スプリングガイドの静的コンテンツ機能
SpringBootの公式文書では、
/static
パスにある静的コンテンツが使用されています.ソース:https://docs.spring.io/spring-boot/docs/2.3.1.RELEASE/reference/html/spring-boot-features.html#boot-features-spring-mvc-static-content
/statuc
パスにhtmlファイルを入れ、urlにファイル名を入れてhtmlファイルを読み込むSpringBootの内部では、最初から
/static
のパスを検索しません.ない場合は、urlを要求するコントローラを検索し、
/resoutces/static
でhello-static.html
ファイルを検索します.Reference
この問題について(スプリングガイド-起動/コアライブラリ/構築方法), 我々は、より多くの情報をここで見つけました https://velog.io/@woply/스프링부트-공부조각テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol