spring-attic / spring-social-samples

Samples of using Spring Social
http://projects.spring.io/spring-social
Apache License 2.0
531 stars 811 forks source link

spring-social-showcase-boot gives error when booting in Eclipse #53

Open robertobsc opened 8 years ago

robertobsc commented 8 years ago

Hi @habuma , hope you are doing fine!!

I am getting error when booting spring-social-showcase-boot in Eclipse. I am running as Java Application as spring boot allows.

Seems that it is not getting the spring social configuration, cause the error is: Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.social.facebook.api.Facebook] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}

wimdeblauwe commented 8 years ago

I managed to get it starting by doing the following changes:

1) In build.gradle, depend on the latest Spring boot version:

classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.3.RELEASE")

2) Also in build.gradle, do not override the versions of spring-social anymore:

compile("org.springframework.social:spring-social-facebook") compile("org.springframework.social:spring-social-facebook-web") compile("org.springframework.social:spring-social-config")

3) Add an application.properties file in src/main/resources:

spring.social.facebook.app-id= spring.social.facebook.app-secret=

After doing this, it still failed because of a similar exception for LinkedIn and Twitter. Since I don't need those at the moment, I added a @Profile("linkedin") and @Profile("twitter") to the classes in org.springframework.social.showcase.linkedin and org.springframework.social.showcase.twitter. If starting without any profile, then Spring Boot will no longer complain that the controllers need that, since they are not started.

I guess that if you want linkedin or twitter, you need to add similar properties in application.properties with linkedin or twitter replacing facebook.

wimdeblauwe commented 8 years ago

Note that the above makes the application start, but still does not work with Facebook. For that you need to change signin.html. Replace:

<input type="hidden" name="scope" value="read_stream,user_posts,user_photos"></input>

With:

<input type="hidden" name="scope" value="email"></input>