简体   繁体   中英

Application Run Failed in SpringBoot

I am learning SpringBoot through a tutorial, building a sample website with an API for a company's employee database. When I try to run the application, I get the following message:

Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loadDatabase' defined in file [/Users/westonjorgensen/Downloads/payroll/target/classes/com/company/payroll/LoadDatabase.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.company.payroll.LoadDatabase$$EnhancerBySpringCGLIB$$6abc07cf]: Constructor threw exception; nested exception is java.lang.Error: Unresolved compilation problems: 
The declared package "payroll" does not match the expected package "com.company.payroll"
The method save(Employee) is undefined for the type EmployeeRepository
The method save(Employee) is undefined for the type EmployeeRepository

The entire project is here https://github.com/wjorgensen/payroll.git

The tutorial I am following is https://spring.io/guides/tutorials/rest/

Any ideas on how to solve the issue?

There is a package problem.

The exception mentions <...>/com/company/payroll/LoadDatabase.class but your project does not contain LoadDatabase.java class in src/main/java/com/company/payroll . Try moving all your classes from com.company.payroll package to payroll package as described in the tutorial you are following.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM