表題の通りです。
IDEはIntelliJでpom.xmlのファイルも編集しreimportsも行ったものの、サーバーも起動しません。
templatesを使用し始めてからうまく動作しなくなりました。
エラーメッセージには、mainClassがないと書いてありますが、今までmainと書かなくても動作していたのですが、、、
参照している教材は『Spring Boot プログラミング入門』という本です。
解決策をご存知の方、教えていただけないでしょうか。
html
1index.html 2 3<!DOCTYPE html> 4<html xmlns:th="http://www.thymeleaf.org"> 5<head> 6 <title>top page</title> 7 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 8 <style> 9 h1 { font-size: 18pt; font-weight: bold; color: gray; } 10 body { font-size:13pt; color: gray; margin:5px 25px;} 11 </style> 12</head> 13<body> 14 <h1>Hello Page</h1> 15 <p class="msg">this is Thymeleaf sample page.</p> 16</body> 17</html>
java
1HelloController.java 2 3package pro.shu; 4 5import org.springframework.stereotype.Controller; 6import org.springframework.web.bind.annotation.RequestMapping; 7 8@Controller 9public class HelloController { 10 @RequestMapping("/") 11 public String index() { 12 return "index"; 13 } 14 15}
xml
1pom.xml 2 3<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 4 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 5 <modelVersion>4.0.0</modelVersion> 6 7 <groupId>pro.shu</groupId> 8 <artifactId>my-spring-boot</artifactId> 9 <version>1.0-SNAPSHOT</version> 10 <packaging>jar</packaging> 11 12 <name>my-spring-boot</name> 13 <url>http://maven.apache.org</url> 14 15 <properties> 16 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 17 </properties> 18 19 <parent> 20 <groupId>org.springframework.boot</groupId> 21 <artifactId>spring-boot-starter-parent</artifactId> 22 <version>1.4.0.RELEASE</version> 23 </parent> 24 25 <dependencies> 26 <dependency> 27 <groupId>org.springframework.boot</groupId> 28 <artifactId>spring-boot-starter-web</artifactId> 29 </dependency> 30 <dependency> 31 <groupId>org.springframework.boot</groupId> 32 <artifactId>spring-boot-starter-thymeleaf</artifactId> 33 </dependency> 34 <dependency> 35 <groupId>junit</groupId> 36 <artifactId>junit</artifactId> 37 <version>4.12</version> 38 <scope>test</scope> 39 </dependency> 40 <dependency> 41 <groupId>org.thymeleaf</groupId> 42 <artifactId>thymeleaf-spring4</artifactId> 43 </dependency> 44 </dependencies> 45 46 <build> 47 <plugins> 48 <plugin> 49 <groupId>org.springframework.boot</groupId> 50 <artifactId>spring-boot-maven-plugin</artifactId> 51 <version>1.4.0.RELEASE</version> 52 <executions> 53 <execution> 54 <goals> 55 <goal>repackage</goal> 56 </goals> 57 </execution> 58 </executions> 59 </plugin> 60 </plugins> 61 </build> 62 63</project>
エラーメッセージ [ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.4.0.RELEASE:run (default-cli) on project my-spring-boot: Unable to find a suitable main class, please add a 'mainClass' property -> [Help 1] [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/MojoExecutionException
java
1package sample.spring; 2 3import org.springframework.context.annotation.Bean; 4import org.springframework.context.annotation.ComponentScan; 5import org.springframework.context.annotation.Configuration; 6import org.springframework.context.annotation.PropertySource; 7import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; 8 9@Configuration 10@ComponentScan 11@PropertySource(value = {"classpath:beans.properties"}) 12public class AppConfig { 13 14 @Bean 15 public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { 16 return new PropertySourcesPlaceholderConfigurer(); 17 } 18 19}