springをApplicationのメインメッソッドで実行したのですがhttp://localhost:8080/roomsにアクセスしても404が返ってくるだけです。
なぜでしょうか。
プロジェクトはSpring Starter Projectで作成しております。
###発生している問題・エラーメッセージ
. ____ _ __ _ _
/\ / ' __ _ () __ __ _ \ \ \
( ( )__ | '_ | '| | ' / ` | \ \ \
\/ __)| |)| | | | | || (| | ) ) ) )
' || .__|| ||| |_, | / / / /
=========||==============|/=////
:: Spring Boot :: (v1.4.3.RELEASE)
2017-01-26 23:19:34.210 INFO 9437 --- [ main] mrs.MrsApplication : Starting MrsApplication on zhushenghehongs-MacBook-Air.local with PID 9437 (/Users/kazuanzo/Documents/Reservation/mrs/target/classes started by kazuanzo in /Users/kazuanzo/Documents/Reservation/mrs)
2017-01-26 23:19:34.213 INFO 9437 --- [ main] mrs.MrsApplication : No active profile set, falling back to default profiles: default
2017-01-26 23:19:34.285 INFO 9437 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@71d44a3: startup date [Thu Jan 26 23:19:34 JST 2017]; root of context hierarchy
2017-01-26 23:19:35.201 INFO 9437 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2017-01-26 23:19:35.277 INFO 9437 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2017-01-26 23:19:35.718 INFO 9437 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$d4aa98e1] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-01-26 23:19:36.076 INFO 9437 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-01-26 23:19:36.092 INFO 9437 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2017-01-26 23:19:36.093 INFO 9437 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.6
2017-01-26 23:19:36.227 INFO 9437 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2017-01-26 23:19:36.227 INFO 9437 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1946 ms
2017-01-26 23:19:36.275 INFO 9437 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-01-26 23:19:36.712 INFO 9437 --- [ main] o.s.jdbc.datasource.init.ScriptUtils : Executing SQL script from URL [file:/Users/kazuanzo/Documents/Reservation/mrs/target/classes/schema.sql]
2017-01-26 23:19:36.925 INFO 9437 --- [ main] o.s.jdbc.datasource.init.ScriptUtils : Executed SQL script from URL [file:/Users/kazuanzo/Documents/Reservation/mrs/target/classes/schema.sql] in 212 ms.
2017-01-26 23:19:36.928 INFO 9437 --- [ main] o.s.jdbc.datasource.init.ScriptUtils : Executing SQL script from URL [file:/Users/kazuanzo/Documents/Reservation/mrs/target/classes/data.sql]
2017-01-26 23:19:36.978 INFO 9437 --- [ main] o.s.jdbc.datasource.init.ScriptUtils : Executed SQL script from URL [file:/Users/kazuanzo/Documents/Reservation/mrs/target/classes/data.sql] in 50 ms.
2017-01-26 23:19:37.185 INFO 9437 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2017-01-26 23:19:37.220 INFO 9437 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2017-01-26 23:19:37.347 INFO 9437 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.0.11.Final}
2017-01-26 23:19:37.349 INFO 9437 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2017-01-26 23:19:37.351 INFO 9437 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2017-01-26 23:19:37.398 INFO 9437 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2017-01-26 23:19:37.535 INFO 9437 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
2017-01-26 23:19:37.860 INFO 9437 --- [ main] o.h.tool.hbm2ddl.SchemaValidator : HHH000229: Running schema validator
2017-01-26 23:19:37.953 INFO 9437 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2017-01-26 23:19:38.602 INFO 9437 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2017-01-26 23:19:38.695 INFO 9437 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2017-01-26 23:19:38.699 INFO 9437 --- [ main] mrs.MrsApplication : Started MrsApplication in 4.994 seconds (JVM running for 5.706)
###該当のソースコード
これがControllerクラスです。 package app; import java.time.LocalDate; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat.ISO; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import model.ReservableRoom; import service.RoomService; @Controller @RequestMapping("rooms") public class RoomsController { @Autowired RoomService roomService; @RequestMapping(method=RequestMethod.GET) String listRooms(Model model){ LocalDate today=LocalDate.now(); List<ReservableRoom> rooms=roomService.findReservableRooms(today); model.addAttribute("date", today); model.addAttribute("rooms", rooms); return "room/listRooms"; } @RequestMapping(value="{date}",method=RequestMethod.GET) String listRooms(@DateTimeFormat(iso=ISO.DATE)@PathVariable("date") LocalDate date,Model model){ List<ReservableRoom>rooms=roomService.findReservableRooms(date); model.addAttribute("rooms",rooms); return"room/listRooms"; } } 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>mrs</groupId> <artifactId>mrs</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>mrs</name> <description>Demo project for Spring Boot</description> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.4.3.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.thymeleaf.extras</groupId> <artifactId>thymeleaf-extras-java8time</artifactId> <version>2.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-solr</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project> ###補足情報(言語/FW/ツール等のバージョンなど) より詳細な情報
回答7件
あなたの回答
tips
プレビュー