我想配置安全(春季安全)申請我的(Maven的)Spring MVC的內彈簧的社會,但是當我試圖訪問/connect/
或/connect/providerid
,我總是得到error 404
春社會/連接返回404
這裏我的GlassFish服務器日誌,當我嘗試訪問:
Info: Mapped "{[/connect/{providerId}],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.view.RedirectView org.springframework.social.connect.web.ConnectController.connect(java.lang.String,org.springframework.web.context.request.NativeWebRequest)
Info: Mapped "{[/connect/{providerId}],methods=[DELETE],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.view.RedirectView org.springframework.social.connect.web.ConnectController.removeConnections(java.lang.String,org.springframework.web.context.request.NativeWebRequest)
Info: Mapped "{[/connect/{providerId}],methods=[GET],params=[error],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.view.RedirectView org.springframework.social.connect.web.ConnectController.oauth2ErrorCallback(java.lang.String,java.lang.String,java.lang.String,java.lang.String,org.springframework.web.context.request.NativeWebRequest)
Info: Mapped "{[/connect/{providerId}/{providerUserId}],methods=[DELETE],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.view.RedirectView org.springframework.social.connect.web.ConnectController.removeConnection(java.lang.String,java.lang.String,org.springframework.web.context.request.NativeWebRequest)
Info: Mapped "{[/connect],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String org.springframework.social.connect.web.ConnectController.connectionStatus(org.springframework.web.context.request.NativeWebRequest,org.springframework.ui.Model)
Info: Mapped "{[/connect/{providerId}],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String org.springframework.social.connect.web.ConnectController.connectionStatus(java.lang.String,org.springframework.web.context.request.NativeWebRequest,org.springframework.ui.Model)
Info: Mapped "{[/connect/{providerId}],methods=[GET],params=[oauth_token],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.view.RedirectView org.springframework.social.connect.web.ConnectController.oauth1Callback(java.lang.String,org.springframework.web.context.request.NativeWebRequest)
Info: Mapped "{[/connect/{providerId}],methods=[GET],params=[code],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.view.RedirectView org.springframework.social.connect.web.ConnectController.oauth2Callback(java.lang.String,org.springframework.web.context.request.NativeWebRequest)
Info: Mapped URL path [/resources/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
Info: Looking for @ControllerAdvice: Root WebApplicationContext: startup date [Thu May 14 16:06:15 PDT 2015]; root of context hierarchy
Info: Using DataSource [[email protected]] of Hibernate SessionFactory for HibernateTransactionManager
Info: Creating filter chain: [email protected]1, [org.springframework.secu[email protected]5b252c00, org.spring[email protected]22de3dd7, [email protected]10, [email protected], org.[email protected]68a35517, org.springframework.s[email protected]4d85d53d, org.sp[email protected]3d704ff, org.springframework.[email protected]57243fe2, org.springfram[email protected]53e99103, o[email protected]1917c313, org[email protected]7977c9b0, org.springfr[email protected]a742949]
Info: Root WebApplicationContext: initialization completed in 3718 ms
Info: WebModule[null] ServletContext.log():Initializing Spring FrameworkServlet 'DispatcherServlet'
Info: FrameworkServlet 'DispatcherServlet': initialization started
Info: FrameworkServlet 'DispatcherServlet': initialization completed in 37 ms
Info: Loading application [social] at [/social]
Info: social was successfully deployed in 6,291 milliseconds.
Severe: PWC6117: File "null" not found
這裏是我的社會配置類:
@Configuration
@EnableSocial
public class SocialConfig implements SocialConfigurer {
@Autowired
DataSource dataSource;
@Override
public void addConnectionFactories(ConnectionFactoryConfigurer cfConfig, Environment env) {
cfConfig.addConnectionFactory(new LinkedInConnectionFactory("consumerKey", "consumerSecret"));
}
@Override
public UsersConnectionRepository getUsersConnectionRepository(ConnectionFactoryLocator connectionFactoryLocator) {
return new JdbcUsersConnectionRepository(dataSource, connectionFactoryLocator, Encryptors.noOpText());
}
@Override
public UserIdSource getUserIdSource() {
return new AuthenticationNameUserIdSource();
}
@Bean
public ConnectController connectController(ConnectionFactoryLocator connectionFactoryLocator, ConnectionRepository connectionRepository) {
return new ConnectController(connectionFactoryLocator, connectionRepository);
}
}
這裏是我的WebAp pliactionInitializer類:
public class WebInitializer implements WebApplicationInitializer {
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
WebApplicationContext context = getContext();
servletContext.addListener(new ContextLoaderListener(context));
ServletRegistration.Dynamic dispatcher = servletContext.addServlet("DispatcherServlet", new DispatcherServlet(context));
dispatcher.setLoadOnStartup(1);
dispatcher.addMapping("/");
}
private AnnotationConfigWebApplicationContext getContext() {
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
context.setConfigLocation("com.gfz.social.springmvc.config"); // java package with all configs
return context;
}
}
我已經檢查過的pom.xml
<!-- Spring Social -->
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-core</artifactId>
<version>1.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-web</artifactId>
<version>1.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-security</artifactId>
<version>1.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-config</artifactId>
<version>1.1.0.RELEASE</version>
</dependency>
有人能幫助我嗎? (我已經嘗試閱讀參考代碼和展示示例) 感謝
這是我的錯誤,我已經從展櫃複製了意見,但我使用jsp而不是html(showcase)。現在,它的工作,謝謝你 – kozima