Reputation: 47
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?
Upvotes: 1
Views: 668
Reputation: 1271
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.
Upvotes: 2