前提・実現したいこと
SpringBootの開発段階での質問です。
【現状】
STSをインストールして、Mavenベースのプロジェクト作成からビルドが行えません。
File > New > Spring Starter Project でプロジェクトの設定を行いました。
そうするとpom.xmlにエラー表示が出て、プロジェクトのビルド(Run > Run as > Maven install)が行えません。
エラーメッセージやpom.xmlの内容を下記に記します。
よろしくお願い致します。
発生している問題・エラーメッセージ
Error
1[INFO] Scanning for projects... 2[INFO] Downloading: https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-parent/2.1.1.RELEASE/spring-boot-starter-parent-2.1.1.RELEASE.pom 3[ERROR] [ERROR] Some problems were encountered while processing the POMs: 4[FATAL] Non-resolvable parent POM for com.tuyano.springboot:MyBootApp:0.0.1-SNAPSHOT: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.1.1.RELEASE from/to central (https://repo.maven.apache.org/maven2): Unexpected response code for CONNECT: 405 and 'parent.relativePath' points at no local POM @ line 16, column 13 5 @ 6[ERROR] The build could not read 1 project -> [Help 1] 7[ERROR] 8[ERROR] The project com.tuyano.springboot:MyBootApp:0.0.1-SNAPSHOT (C:\Users\×××××\Documents\workspace-sts-3.9.2.RELEASE\MyBootApp\pom.xml) has 1 error 9[ERROR] Non-resolvable parent POM for com.tuyano.springboot:MyBootApp:0.0.1-SNAPSHOT: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.1.1.RELEASE from/to central (https://repo.maven.apache.org/maven2): Unexpected response code for CONNECT: 405 and 'parent.relativePath' points at no local POM @ line 16, column 13 -> [Help 2] 10[ERROR] 11[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 12[ERROR] Re-run Maven using the -X switch to enable full debug logging. 13[ERROR] 14[ERROR] For more information about the errors and possible solutions, please read the following articles: 15[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException 16[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException
該当のソースコード
pom.xml
1<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 2 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 3 <modelVersion>4.0.0</modelVersion> 4 5 <groupId>com.tuyano.springboot</groupId> 6 <artifactId>MyBootApp</artifactId> 7 <version>0.0.1-SNAPSHOT</version> 8 <name>MyBootApp</name> 9 <description>Sample project for Spring Boot</description> 10 11 <properties> 12 <!-- 13 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> --> 14 <java.version>1.8</java.version> 15 </properties> 16 17 <dependencyManagement> 18 <dependencies> 19 <dependency> 20 <groupId>org.springframework.boot</groupId> 21 <artifactId>spring-boot-starter-parent</artifactId> 22 <version>2.1.1.RELEASE</version> 23 <scope>import</scope> 24 </dependency> 25 </dependencies> 26 </dependencyManagement> 27 28 <dependencies> 29 <dependency> 30 <groupId>org.springframework.boot</groupId> 31 <artifactId>spring-boot-starter-web</artifactId> 32 <version>2.1.1.RELEASE</version> 33 <scope>import</scope> 34 </dependency> 35 <dependency> 36 <groupId>org.springframework.boot</groupId> 37 <artifactId>spring-boot-starter-test</artifactId> 38 <version>2.1.1.RELEASE</version> 39 <scope>import</scope> 40 </dependency> 41 </dependencies> 42 43 <profiles><!-- プロファイルを設定する --> 44 <profile> 45 <id>product</id> 46 <properties> 47 <mykey>productvalue</mykey> 48 </properties> 49 </profile> 50 </profiles> 51 52 <build> 53 <plugins> 54 <plugin> 55 <groupId>org.springframework.boot</groupId> 56 <artifactId>spring-boot-maven-plugin</artifactId> 57 <configuration> 58 <mainClass>com.techscore.spring_boot_sample.HelloController</mainClass> 59 </configuration> 60 </plugin> 61 </plugins> 62 </build> 63 64</project>
変更後のpom.xml 等
pom
1<?xml version="1.0" encoding="UTF-8"?> 2<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 3 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4 <modelVersion>4.0.0</modelVersion> 5 6 <groupId>com.tuyano.springboot</groupId> 7 <artifactId>MyBootApp</artifactId> 8 <version>0.0.1-SNAPSHOT</version> 9 <name>MyBootApp</name> 10 <description>Sample project for Spring Boot</description> 11 12 <properties> 13 <java.version>1.8</java.version> 14 </properties> 15 16 <parent> 17 <groupId>org.springframework.boot</groupId> 18 <artifactId>spring-boot-starter-parent</artifactId> 19 <version>2.1.1.RELEASE</version> 20 <relativePath/> <!-- lookup parent from repository --> 21 </parent> 22 23 <dependencies> 24 <dependency> 25 <groupId>org.springframework.boot</groupId> 26 <artifactId>spring-boot-starter-web</artifactId> 27 </dependency> 28 29 <dependency> 30 <groupId>org.springframework.boot</groupId> 31 <artifactId>spring-boot-starter-test</artifactId> 32 <scope>test</scope> 33 </dependency> 34 </dependencies> 35 36 <profiles><!-- プロファイルを設定する --> 37 <profile> 38 <id>product</id> 39 <properties> 40 <mykey>productvalue</mykey> 41 </properties> 42 </profile> 43 </profiles> 44 45 <build> 46 <plugins> 47 <plugin> 48 <groupId>org.springframework.boot</groupId> 49 <artifactId>spring-boot-maven-plugin</artifactId> 50 </plugin> 51 </plugins> 52 </build> 53 54</project>
MyBootAppApplication
1package com.tuyano.springboot; 2 3import org.springframework.boot.SpringApplication; 4import org.springframework.boot.autoconfigure.SpringBootApplication; 5import org.springframework.boot.SpringApplication; 6import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 7import org.springframework.web.bind.annotation.RequestMapping; 8import org.springframework.web.bind.annotation.RestController; 9 10@RestController 11@EnableAutoConfiguration 12@SpringBootApplication 13public class MyBootAppApplication { 14 15 @RequestMapping("/") 16 String home(){ 17 return "Hello World !"; 18 } 19 20 public static void main(String[] args) { 21 SpringApplication.run(MyBootAppApplication.class, args); 22 } 23}
applicationproperties
1spring.application.name=cruncher 2spring.datasource.driverClassName=com.mysql.jdbc.Driver 3spring.datasource.url=jdbc:mysql://localhost/test 4server.port=×××
試したこと
・Maven > Update project → Run as > Maven cleanを実行。(Maven cleanで既に上記のエラーが出る)
・STSのバージョンを最新のものにして実行。
・JDKを10にして実行。
・pom.xmlに<profiles>~<profiles>や<build>~</build>を追記。
・"Eclipseで、アクティブMavenプロファイルに「pom.xml」が指定されているのが原因"という書き込みのサイト(https://qiita.com/yuji38kwmt/items/84927f21c71a163724f1)を見つけたが、アクティブMavenプロファイルが見当たらない。
補足情報(FW/ツールのバージョンなど)
STS 3.9.2
maven 3.6.0
JDK 8

回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/12/19 01:35
2018/12/19 08:01
2018/12/20 07:59
2018/12/20 09:32
退会済みユーザー
2018/12/20 10:06
2018/12/25 01:45
2018/12/25 06:40
2020/03/05 04:07