私の意図は、既存のプロジェクトに 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");
}
それで、それらは私の元のスキャンで検出されますか? どのようにそれらを統合する必要がありますか??
ありがとう!