Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialSteve Fielding
7,287 PointsNeed Help With UserDao
Hi, Anytime i create the User findByUsername(String username) function under UserDao is get an error
public interface UserDao extends CrudRepository<User, Long> {
User findByUsername(String username);
}
Error
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDao': Invocation of init method failed; nested exception is java.lang.AbstractMethodError: org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolve
But when i take it out the error goes away. I can't figure out what is wrong
4 Answers
Chris Jones
Java Web Development Techdegree Graduate 23,933 PointsHey Molayo,
This might not be the problem, but do you have a class implementing the interface?
J.D. Sandifer
18,813 PointsA quick online search suggests: "This issue might be arising due to incompatibility of spring-data-commons jar and Spring-data-jpa jars. Please check this using mvn dependency:tree command." (From StackOverflow.)
Steve Fielding
7,287 Points@J.D. Sandifer, You are right. I couldn't figure out what was incompatible with what so i changed the build.gradle file to the same mvn dependencies in the video and it's working fine. The only down side is that i am not using an updated version of the man dependencies.
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 PointsInteresting problem.
But I need more information. If you push the Gradle project to the GitHub and share a link, I can take a look and try to reproduce. Otherwise, it is hard to help.
vikas Rai
9,703 PointsCan you please let me know, what you changed?
Sahil Chawla
5,834 PointsI have the same problem.
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDao': Could not resolve matching constructor (hint: specify index/type/name arguments for simple parameters to avoid type ambiguities) at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:240) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1193) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1095) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getSingletonFactoryBeanForTypeCheck(AbstractAutowireCapableBeanFactory.java:923) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryBean(AbstractAutowireCapableBeanFactory.java:804) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.isTypeMatch(AbstractBeanFactory.java:558) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:432) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:395) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE] at org.springframework.beans.factory.BeanFactoryUtils.beanNamesForTypeIncludingAncestors(BeanFactoryUtils.java:220) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]