
前提・実現したいこと
STSでGradleを利用して作成したプロジェクトのbild.gradleの内容が参考書と異なるため
同じ内容にするにはどうすればよいでしょうか。
発生している問題・エラーメッセージ
SpringBott2の参考書を勉強しているのですが、STSでGradleを利用するという内容で疑問になった点があり質問させて頂きます。
STSでは、標準ではGradleを利用するための機能がないため、プラグインを導入する必要があると記載があり参考書で指定されたプラグインを導入しようと思い「新規ソフトウェアのインストール」で以下のアドレスを利用しました。
(参考書に記載されたものです。)
http://download.eclipse.org/buildship/updates/e46/releases/2.x/2.0.0.v20170111-1029/
ただ、ダウンロード時エラーが発生したため、buildship Gradle Integration 3.0を導入しました。
その後、STSの
ファイル> 新規 >Spring スタータープロジェクトを選択し新規のプロジェクトを作成しました。
(設定はほぼデフォルトですが、型の箇所が参考書ではGradle(Builsship 2.x)となっていましたが2.0に変更すると2.0がインストールされていないのでエラーとなるため3.xにしています)
ここで、作成されたbuild.gradleの内容を確認すると、
参考書だと以下の様になっています。
html
1buildscript{ 2 ext{ 3 springBootVersion = '2.0.0.RELEASE' 4 } 5 respositories{ 6 mavenCentral() 7 maven{ url "https://repo.spring.io/snapshot"} 8 maven{ url "https://repo.spring.io/milestone"} 9 } 10 dependencies{ 11 calsspath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 12 } 13 14apply plugin:'java' 15apply plugin:'eclipse' 16apply plugin: 'org.springframework.boot' 17apply plugin:'io.spring.dependency-management' 18 19 20version = '0.0.1-SNAPSHOT' 21sourceCompatibility = '1.8' 22 23 repositories { 24 mavenCentral() 25 } 26 27 dependencies { 28 implementation 'org.springframework.boot:spring-boot-starter-web' 29 testImplementation 'org.springframework.boot:spring-boot-starter-test' 30 } 31 32}
作成した自分の環境のファイルは以下の様になっています。
html
1plugins { 2 id 'org.springframework.boot' version '2.1.4.RELEASE' 3 id 'java' 4} 5 6apply plugin: 'io.spring.dependency-management' 7 8group = 'com.xx.springboot' 9version = '0.0.1-SNAPSHOT' 10sourceCompatibility = '1.8' 11 12repositories { 13 mavenCentral() 14} 15 16dependencies { 17 implementation 'org.springframework.boot:spring-boot-starter-web' 18 testImplementation 'org.springframework.boot:spring-boot-starter-test' 19} 20
この場合、参考書にあったbuildscriptやapply pluginなどを自分の環境のコードに貼り付れば同じ動きになるのでしょうか。
それとも、他のプラグインを導入しないと同じ様にはならないのでしょうか。
補足情報(FW/ツールのバージョンなど)
STSのVersion: 3.9.7.RELEASE
gradleのgradle-5.4.1
OS:Mac
もし他に必要な情報がありましたら、申し訳ないですがお声かけください。



回答1件
あなたの回答
tips
プレビュー