Reputation: 1
spring io facebook accessing is giving spring boot app, which registers through facebook with spring-boot-starter-parent version "1.5.10.RELEASE"
it is working correctly but when I changed the version to 2.0.0.RELEASE
it did not work and it gave me this error:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run(AbstractRunMojo.java:496)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'helloController' defined in file [C:\Users\NOSIRAT\Documents\NetBeansProjects\gs-accessing-face\gs-accessing-facebook-master\complete\target\classes\hello\HelloController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.social.facebook.api.Facebook' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:729)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:192)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1270)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1127)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:760)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:868)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1234)
at hello.Application.main(Application.java:10)
... 6 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.social.facebook.api.Facebook' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1509)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1104)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1065)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:815)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:721)
... 24 more
I have added version to spring-social-facebook
because there was compiler error, I tried <version>3.0.0.M3</version>
and tried <version>2.0.3.RELEASE</version>
but none of them solved the problem.
How can I fix this? Any help please..
Upvotes: 0
Views: 1325
Reputation: 912
I'm in the same boat trying to get Facebook auth working in Spring Boot. I tried a number of tutorials that failed miserably once I tried to upgrade the dependencies or slightly modify them. Digging through the pom files I discovered that Spring Boot 2.0 uses Spring Core 5 while Spring Boot 1.5 and Social Facebook uses Spring Core 4 making them inherently incompatible. Spring Social Facebook also seems to have a deprecated version of the Facebook Graph API 2.5 and I'm pretty sure it only uses OAuth v1, although I didn't confirm.
As someone that hasn't used Spring in a few years, I definitely feel like the documentation is lacking a clear direction. Even though there hasn't been an update to Spring Social Facebook since 2015 (excluding milestones) there are still tutorials as recently as 2017 that I found. None of them appeared to implement a basic configuration the same way so I kept getting stumped as to why they were different.
Eventually, I ran across a blog post from March 2018 by one of the listed maintainers of Spring Social that used Spring Security. You might want to check this link out or just google Spring Boot OAuth2.
Very frustrating wasting time on this when there is no indication on the Spring Social main site that I should use Spring Security OAuth2 instead.
Upvotes: 1
Reputation: 1812
According to spring boot 2.0 migration guid here some features are removed and you have to add dependencies related to this by yourself. It also contains
Auto-configuration and dependency management for Spring Social. Please check the Spring Social project for more details.
To make your configuration work please add below dependencies with your spring boot version 2.0.0
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-facebook</artifactId>
<version>3.0.0.M1</version>
</dependency>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-core</artifactId>
<version>2.0.0.M2</version>
</dependency>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-config</artifactId>
<version>2.0.0.M2</version>
</dependency>
Upvotes: 0