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

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

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

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

Spring Boot

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

Q&A

解決済

3回答

22260閲覧

Springbootを使ってみたいのですがimportのエラーの解消方法がわかりません。

moshi

総合スコア90

Java

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

Spring Boot

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

0グッド

0クリップ

投稿2018/12/25 03:32

Spring bootの勉強中です。
MavenでSpringBootのプロジェクトをEclipseで作成しています。

SpringBootのリファレンスに以下の文があったのでまずはMainクラスを作成してみようと思いました。

The Application.java file would declare the main method, along with the basic @SpringBootApplication, as follows:

package com.example.myapplication; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } }

するとimportのorg.springframework.bootのところでエラーが出ていたので調べてみたところPOMファイルに依存関係を記述しなければいけなそうだったので、最重用とあった

<!-- 最重要。Spring Bootの諸々設定を引き継ぐための親情報。 --> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.2.1.RELEASE</version> </parent>

のところをコピーしてPOMファイルに記述しました。
この時点でビルドしてみたら<parent>のところにエラーのマークがついていて

プロジェクト・ビルド・エラー: Non-resolvable parent POM for jp.org:web:1.0.0-BUILD-SNAPSHOT: Failure to transfer org.springframework.boot:spring-boot-starter-parent:pom:1.2.1.RELEASE from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. オリジナル・エラー: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:1.2.1.RELEASE from/to central (https://repo.maven.apache.org/maven2): proxy.example.com and 'parent.relativePath' points at wrong local POM

というメッセージが出されていました。

どうすればorg.springframework.bootが使えるようになるでしょうか?

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

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

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

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

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

guest

回答3

0

1.2.1.RELEASE

ではなく

2.1.1.RELEASE

ではないかなぁと。

投稿2018/12/25 06:42

A-pZ

総合スコア12011

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

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

0

ベストアンサー

プロジェクトを右クリック>Maven>プロジェクトの更新
を、試してみたらいかがでしょうか?
最初はこの操作が必要だったと思います。

投稿2018/12/25 06:40

greeash

総合スコア30

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

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

0

バージョンが古いのかな。

pom.xmlファイルは自作しなくてもEclipseにSpringBootのプラグインを追加すればプロジェクトを作成してくれると思いますよ。

プロジェクトはhttps://start.spring.io/でも作成できます。

作成するとpom.xmlファイルはこんな感じになると思います。

<?xml version="1.0" encoding="UTF-8"?> <project 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/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.1.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.example</groupId> <artifactId>demo</artifactId> <version>0.0.1-SNAPSHOT</version> <name>demo</name> <description>Demo project for Spring Boot</description> <properties> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>

投稿2018/12/25 05:44

apo

総合スコア349

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

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

moshi

2018/12/25 06:04

Eclipseが自動生成してくれたpom.xmlファイルでも<parent>のところで 「プロジェクト・ビルド・エラー: Non-resolvable parent POM for com.bootsample:bootsample:0.0.1-SNAPSHOT: Failure to transfer org.springframework.boot:spring-boot-starter-parent:pom:2.1.1.RELEASE from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. オリジナル・エラー: 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): proxy.example.com and 'parent.relativePath' points at no local POM」 というエラーが出力されてしまいます…
apo

2018/12/25 06:35

すみません、わからないなぁ。 mvn clean実行後に mvn compileしてもだめですかね?
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問