質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Spring

Spring Framework は、Javaプラットフォーム向けのオープンソースアプリケーションフレームワークです。 Java Platform上に、 Web ベースのアプリケーションを設計するための拡張機能が数多く用意されています。

Spring Boot

Spring Bootは、Javaのフレームワークの一つ。Springプロジェクトが提供する様々なフレームワークを統合した、アプリケーションを高速で開発するために設計されたフレームワークです。

Q&A

解決済

2回答

13676閲覧

【SpringBoot】Mavenベースのプロジェクト作成からビルドが行えない

150be

総合スコア20

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Spring

Spring Framework は、Javaプラットフォーム向けのオープンソースアプリケーションフレームワークです。 Java Platform上に、 Web ベースのアプリケーションを設計するための拡張機能が数多く用意されています。

Spring Boot

Spring Bootは、Javaのフレームワークの一つ。Springプロジェクトが提供する様々なフレームワークを統合した、アプリケーションを高速で開発するために設計されたフレームワークです。

0グッド

0クリップ

投稿2018/12/14 08:09

編集2018/12/18 02:25

前提・実現したいこと

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

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答2

0

ベストアンサー

pom.xmlのprofileにてproductを指定していますので、mavenのsettings.xmlにもproductの設定があって、例えば更新されていないリポジトリなどがあったり、有効でないプロキシ設定があって動作しないなどあるでしょうか。

投稿2018/12/18 08:13

A-pZ

総合スコア12011

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

150be

2018/12/19 01:35

ご連絡頂き、誠にありがとうございます。 質問内容が3点あると認識していますので、1つずつの解答を以下に記します。 ①pom.xmlのprofileにてproductを指定しているが、  mavenのsettings.xmlにもproductの設定があるか? A:mavenのsetting.xmlを確認してみたところ  profile内でproduct設定している箇所はありません。 ②更新されていないリポジトリなどがあるか? A:${user.home}/.m2直下のリポジトリ内を確認したところ、  更新はかかっているので、更新されていないのは存在しない。 ③有効でないプロキシ設定があって動作しない? A:setting.xmlに記載してあるプロキシに関しては、有効であると認識している 以上となります。よろしくお願い致します。
A-pZ

2018/12/19 08:01

不要なプロファイル設定がある場合は削除すべきでしょう。それはいいとして、ビルド時のエラーを見ると、https://repo.maven.apache.org/maven2: Unexpected response code for CONNECT: 405 and 'parent.relativePath' points at no local POM とあるので、お使いのビルド環境から maven centralを参照しようとして 405(METHOD NOT ALLOWED)がレスポンスされた結果になっており、setting.xmlにて記載されているプロキシから取得が許可されていないようです。接続の設定に問題がないのであればあとはプロキシ側の問題もあるかと思いますので、ブラウザで同じプロクシ設定をした後に、https://repo.maven.apache.org/maven2 が参照可能であるかを確認してから、プロキシの設定内容を確認すれば問題が特定できるかもしれません。
A-pZ

2018/12/20 09:32

プロキシを特に設定せずにブラウザで参照できるなら、プロキシ側の問題ではないでしょうか。(そうであればmavenのプロキシ設定は不要だと思いますが。)
退会済みユーザー

退会済みユーザー

2018/12/20 10:06

これの場合、空のプロファイル(pom.xml)を作成しないといけない方、 古い設定があるとかではなくて
150be

2018/12/25 01:45

>A-pZ ありがとうございました。プロキシ側に問題がありました。
A-pZ

2018/12/25 06:40

d(・ω・
boliver

2020/03/05 04:07

>150be 突然すいません 全く同じエラーが出ているのですが、プロキシ側の問題とは具体的にどう修正されたか教えていただけないでしょうか
guest

0

STSが生成したpom.xmlをなにかを参考にして修正されたのだと思いますが、エラーメッセージにあるように少し書き方におかしな点があります。

たとえば、spring-boot-starter-webpring-boot-starter-testのscopeがimportになっている点がワーニングとして出力されています。
メッセージによれば、これらのscopeはprovided, compile, runtime, test, systemのどれかになります。

以下のpom.xmlを参考に修正してみてください。
これはSTS 4.0.2で生成したSpring Bootプロジェクトに含まれているpom.xmlに少し手を加えたものです。

xml

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>

投稿2018/12/14 14:38

rubytomato

総合スコア1752

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

150be

2018/12/17 01:22

ご連絡頂き、誠にありがとうございます。 本日、試してみたところエラー内容には変化があったものの、依然pom.xmlにエラーは 出現しています。 以下、エラー内容です。 [INFO] Scanning for projects... [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 [ERROR] [ERROR] Some problems were encountered while processing the POMs: [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): Failed to connect to /××.×××.×××.×:××× and 'parent.relativePath' points at no local POM @ line 17, column 10 @ [ERROR] The build could not read 1 project -> [Help 1] [ERROR] [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 [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): Failed to connect to /××.×××.×××.×:××× and 'parent.relativePath' points at no local POM @ line 17, column 10: Connection refused: connect -> [Help 2] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException [ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException ・エラー箇所ですが、<parent>についている状態です。 ・また、エラーは出ておりませんが、<artifactId>spring-boot-maven-plugin</artifactId>のmaven-pluginの箇所に波線が引かれています。 エラー内容を見たところ、親POMからの引継ぎに問題があるのでしょうか? ご回答のほど、よろしくお願い致します。
rubytomato

2018/12/17 13:31

更新後のpom.xmlの内容とその結果のエラーメッセージを質問文の方にも追記して頂けますでしょうか? それと似たような現象でのQAがあったので、こちらもご確認ください。 Springスタータープロジェクト作成時にpom.xmlがエラーになってしまう https://teratail.com/questions/135900 【spring-boot】EclipseでMaven依存関係フォルダができない https://teratail.com/questions/135900
150be

2018/12/18 02:31

ご連絡ありがとうございます。 更新後のpom.xmlや対応後の内容などを質問文の方に追記しております。 文字制限の関係で、エラーメッセージは「発生している問題・エラーメッセージ」の項目に上書きしています。 ご確認ください。 以下、似たような現象を基に行った対応内容となります。 ①Springスタータープロジェクト作成時にpom.xmlがエラーになってしまう 〇.m2直下のsetting.xmlの配置場所の変更 現状:setting.xmlは${user.home}/.m2/settings.xmlと ${maven.home}/conf/settings.xmlに存在している 対応:C:\Users[アカウント].m2\repository配下を全て削除 ↓ ${user.home}/.m2/settings.xmlをrepository内に移動 ↓ Maven Cleanを実行 調査:対応後も同エラーは出現。 下記URLを参照してみたが、.m2の配置場所に問題は無いと考える。 https://maven.apache.org/settings.html ②【spring-boot】EclipseでMaven依存関係フォルダができない 〇「Demo4Application.java」「application.properties」を編集 現状:Demo4Application.java、application.propertiesが空白。 対応:質問ページ(https://teratail.com/questions/41230)を参考に編集。  →質問内容に追記しております。 ↓ Maven Cleanを実行 調査:対応後も同エラーは出現 WARNINGは出現していないため、pom.xmlのタグに誤りはない。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問