2017-07-14 192 views
0

我嘗試了一個webapp的Spring引導。當我嘗試啓動我的服務器時,我收到一條錯誤消息:運行彈簧引導應用程序時出錯

我在網上找不到任何類似的帖子,所以我引用了stackoverflow。 在此先感謝!

2017-07-14 10:37:47.525 WARN 10452 --- [   main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerAdapter' defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]: Factory method 'requestMappingHandlerAdapter' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcConversionService' defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.format.support.FormattingConversionService]: Factory method 'mvcConversionService' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property lastName found for type User! 
2017-07-14 10:37:47.525 INFO 10452 --- [   main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default' 
2017-07-14 10:37:47.525 INFO 10452 --- [   main] o.apache.catalina.core.StandardService : Stopping service [Tomcat] 
2017-07-14 10:37:47.540 INFO 10452 --- [   main] utoConfigurationReportLoggingInitializer : 

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled. 
2017-07-14 10:37:47.540 ERROR 10452 --- [   main] o.s.boot.SpringApplication    : Application startup failed 

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerAdapter' defined in class path resource [ 

Application.properties:

spring.datasource.url = jdbc:mysql://localhost:3306/test?verifyServerCertificate=false&useSSL=false&requireSSL=false 
spring.datasource.driverClassName = com.mysql.jdbc.Driver 
spring.datasource.username=Stack0verFlow 
spring.datasource.password=Stack0verFlow 
spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect 
spring.jpa.show-sql=true 
spring.jpa.hibernate.ddl-auto=update 
spring.thymeleaf.cache=false 

的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> 

    <groupId>com.flowcode</groupId> 
    <artifactId>WebApp</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <packaging>jar</packaging> 

    <name>WebApp</name> 
    <description>Demo project for Spring Boot</description> 

    <parent> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-parent</artifactId> 
     <version>1.5.4.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.boot</groupId> 
      <artifactId>spring-boot-starter-data-jpa</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-security</artifactId> 
     </dependency> 
     <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>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> 
    </dependencies> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.springframework.boot</groupId> 
       <artifactId>spring-boot-maven-plugin</artifactId> 
      </plugin> 
     </plugins> 
    </build> 


</project> 
+1

您錯過了異常跟蹤中最有趣的部分。什麼是嵌套異常? – alfcope

回答

1

正如在評論中提到的,例外的某些部分缺失。

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository 

和:但是,這個問題也可以在堆棧跟蹤的第一線發現

org.springframework.data.mapping.PropertyReferenceException: No property lastName found for type User! 

所以,你應該檢查你的UserRepository,因爲你有一個查詢或方法名稱即使在User實體中沒有一個屬性,也會引用名爲lastName的屬性。

相關問題