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 trial

Java Implementing a UserDetailsService

Steve Fielding
Steve Fielding
7,287 Points

Need 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

J.D. Sandifer
J.D. Sandifer
18,813 Points

A 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
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
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 Points

Molayo Decker

Interesting 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
vikas Rai
9,703 Points

Can you please let me know, what you changed?

Sahil Chawla
Sahil Chawla
5,834 Points

I 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]