掲題の勉強で参考書を購入しその通りに行いましたが実行できませんでした。
●行ったこと
コマンドラインからMavenプロジェクトを作成し、pom、App.javaを編集、コントローラークラスを作成。実行。
コマンドラインからMavenプロジェクトを作成
・mvn archetype:generate
pom編集
<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> <groupId>jp.tuyano.spring.boot.myapp1</groupId> <artifactId>MyBootApp1</artifactId> <version>0.0.1-SNAPSHOT</version> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.0.2.BUILD-SNAPSHOT</version> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies> </project> </xml>
App.javaを編集
package
1 2import org.springframework.boot.SpringApplication; 3import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 4import org.springframework.context.ApplicationContext; 5import org.springframework.context.annotation.ComponentScan; 6import org.springframework.context.annotation.Configuration; 7 8@Configuration 9@EnableAutoConfiguration 10@ComponentScan 11public class App 12{ 13 public static void main( String[] args ) 14 { 15 ApplicationContext ctx = SpringApplication.run(App.class, args); 16 } 17} 18
コントローラークラス作成
package
1 2import org.springframework.web.bind.annotation.RestController; 3import org.springframework.web.bind.annotation.RequestMapping; 4 5 6@RestController 7public class HeloController 8{ 9 @RequestMapping("/") 10 public String index() { 11 return "Hello, Spring Boot!"; 12 } 13} 14 15
実行。
mvn spring-boot:run
エラー内容。
No plugin found for prefix 'spring-boot' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories[・・・・・・・・・・・・・
pom編集に関してプロジェクト作成時にversionを「1.0-SNAPSHOT」と作るように書いてあり作りましたが、編集には「0.0.1-SNAPSHOT」と記載するようになっていたため記載してあります。
早くHello,Spring Boot!見てみたく、よろしくお願いしますm(_ _)m
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/05/15 04:56