0

私の意図は、既存のプロジェクトに Spring 4 Websocket クラスをプラグインすることです。Spring Websocket プロジェクトのリンクは次のとおりです: https://github.com/rstoyanchev/spring-websocket-test

問題は、websocket プロジェクトが非常に奇妙な Java ファイル構成を使用しているのに対し、私のプロジェクトは xml 構成ファイルを使用していることです。

私の質問は、これらの構成ファイルを春のプロジェクトから既存の (xml ベースの) プロジェクトにインポートする方法はありますか?

たとえば、私のxmlはweb.xmlで参照されていますが、春のwebsocketプロジェクトにはweb.xmlがまったくありません..

PS そのプロジェクトのすべての構成クラスがコンポーネントであるとは限りません。 @Configuration 注釈のない 2 つのクラスを次に示します。

  import javax.servlet.ServletContext;
  import javax.servlet.ServletException;
 import javax.servlet.ServletRegistration.Dynamic;

import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;

public class DispatcherServletInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {


@Override
protected Class<?>[] getRootConfigClasses() {
    return new Class<?>[] { WebSecurityConfig.class };
}

@Override
protected Class<?>[] getServletConfigClasses() {
    return new Class<?>[] { WebConfig.class, WebSocketConfig.class };
}

@Override
protected String[] getServletMappings() {
    return new String[] { "/" };
}

@Override
protected void customizeRegistration(Dynamic registration) {
    registration.setInitParameter("dispatchOptionsRequest", "true");
}

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    super.onStartup(servletContext);
}

}

@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

@Override
protected void configure(HttpSecurity http) throws Exception {
    http
        .csrf().disable() //TODO Refactor login form
        .authorizeRequests()
            .antMatchers("/assets/**").permitAll()
            .anyRequest().authenticated()
            .and()
        .logout()
            .logoutSuccessUrl("/login.html?logout")
            .logoutUrl("/logout.html")
            .permitAll()
            .and()
        .formLogin()
            .defaultSuccessUrl("/index.html")
            .loginPage("/login.html")
            .failureUrl("/login.html?error")
            .permitAll();
}


@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth
        .inMemoryAuthentication()
            .withUser("fabrice").password("fab123").roles("USER").and()
            .withUser("paulson").password("bond").roles("ADMIN","USER");
}

それで、それらは私の元のスキャンで検出されますか? どのようにそれらを統合する必要がありますか??

ありがとう!

4

2 に答える 2

0

Spring 4 がリリースされたので、プロジェクトに依存関係として簡単に含めることができます: http://search.maven.org/#artifactdetails%7Corg.springframework%7Cspring-framework-bom%7C4.0.0.RELEASE%7Cpom

于 2013-12-13T07:49:11.283 に答える
0

Spring Security 3.2 で Spring 4 WebSockets を使用して、通常の Spring MVC アプリケーションを WebSockets で「レトロフィット」する方法に関する詳細なチュートリアル/例を作成しました。ここをクリック_

于 2014-01-20T11:54:24.070 に答える