问题
I want to overload callbackUrl in ConnectSupport
I use Spring boot Connect : org.springframework.social:spring-social-core:jar:1.1.0.RELEASE:compile
@Bean
public ConnectController connectController(
ConnectionFactoryLocator connectionFactoryLocator,
ConnectionRepository connectionRepository) {
ConnectController controller = new ConnectController(connectionFactoryLocator,
connectionRepository);
controller.set callbackUrl ??
return controller;
}
回答1:
Spring Social Api is available here. You need to call the setApplicationUrl().
@Bean
public ConnectController connectController(ConnectionFactoryLocator connectionFactoryLocator,
ConnectionRepository connectionRepository) {
ConnectController controller = new ConnectController(connectionFactoryLocator,
connectionRepository);
String url = "www.foo.com";
controller.setApplicationUrl(url) ;
return controller;
}
回答2:
At this point (NullPointerException problem) one way to solve the problem is to extend ConnectController (and ProviderSignInController which suffers the same issue) and fix the offending portion of the code yourself. Just adding the classes into project works. Is it elegant? Well...
/*******************************************************************/
//RedirectedConnectController.java
public class RedirectedConnectController extends ConnectController {
@Value("${application.url}")
private String appUrl;
public RedirectedConnectController(ConnectionFactoryLocator connectionFactoryLocator,
ConnectionRepository connectionRepository) {
super(connectionFactoryLocator, connectionRepository);
}
/*
* This is the method, which should be called BEFORE setApplicationUrl
* but obviously is not.
*/
@Override
public void afterPropertiesSet() throws Exception {
super.afterPropertiesSet();
setApplicationUrl(appUrl);
}
}
/*******************************************************************/
//RedirectedSignInController.java
@Controller
public class RedirectedSignInController extends ProviderSignInController {
@Value("${application.url}")
private String appUrl;
@Inject
public RedirectedSignInController(ConnectionFactoryLocator connectionFactoryLocator,
UsersConnectionRepository usersConnectionRepository,
SignInAdapter signInAdapter) {
super(connectionFactoryLocator, usersConnectionRepository, signInAdapter);
}
@Override
public void afterPropertiesSet() throws Exception {
super.afterPropertiesSet();
setApplicationUrl(appUrl);
}
}
来源:https://stackoverflow.com/questions/27593441/spring-boot-callbackurl-connectsupport