Update config
parent
a6141a6e53
commit
d8c2871891
|
@ -1,45 +0,0 @@
|
||||||
package com.monkeyk.sos.config;
|
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.jdbc.core.JdbcTemplate;
|
|
||||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
|
||||||
import org.springframework.transaction.PlatformTransactionManager;
|
|
||||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 2016/4/4
|
|
||||||
* <p/>
|
|
||||||
* Replace context.xml, transaction.xml
|
|
||||||
*
|
|
||||||
* @author Shengzhao Li
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
@ComponentScan(basePackages = "com.monkeyk.sos")
|
|
||||||
//@PropertySource(value = {"classpath:spring-oauth-server.properties"})
|
|
||||||
@EnableTransactionManagement()
|
|
||||||
public class ContextConfigurer {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Bean(name = "transactionManager")
|
|
||||||
public PlatformTransactionManager transactionManager(DataSource dataSource) {
|
|
||||||
DataSourceTransactionManager transactionManager = new DataSourceTransactionManager();
|
|
||||||
transactionManager.setDataSource(dataSource);
|
|
||||||
return transactionManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Bean(name = "jdbcTemplate")
|
|
||||||
public JdbcTemplate jdbcTemplate(DataSource dataSource) {
|
|
||||||
return new JdbcTemplate(dataSource);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,78 +0,0 @@
|
||||||
package com.monkeyk.sos.config;
|
|
||||||
|
|
||||||
import com.monkeyk.sos.web.filter.CharacterEncodingIPFilter;
|
|
||||||
import org.springframework.web.filter.DelegatingFilterProxy;
|
|
||||||
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
|
|
||||||
import org.springframework.web.util.Log4jConfigListener;
|
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
|
||||||
import javax.servlet.ServletException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 2016/4/3
|
|
||||||
* <p/>
|
|
||||||
* Config DispatchServlet
|
|
||||||
* <p/>
|
|
||||||
* Replace web.xml
|
|
||||||
*
|
|
||||||
* @author Shengzhao Li
|
|
||||||
*/
|
|
||||||
public class ServletInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String[] getServletMappings() {
|
|
||||||
return new String[]{"/"};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStartup(ServletContext servletContext) throws ServletException {
|
|
||||||
super.onStartup(servletContext);
|
|
||||||
|
|
||||||
// servletContext.setAttribute("webAppRootKey", "spring-oauth-server");
|
|
||||||
servletContext.setInitParameter("webAppRootKey", "spring-oauth-server");
|
|
||||||
// servletContext.setInitParameter("contextConfigLocation", "classpath:spring/*.xml");
|
|
||||||
servletContext.setInitParameter("log4jConfigLocation", "/WEB-INF/log4j.xml");
|
|
||||||
|
|
||||||
//Add Filters
|
|
||||||
|
|
||||||
CharacterEncodingIPFilter characterEncodingIPFilter = new CharacterEncodingIPFilter();
|
|
||||||
characterEncodingIPFilter.setEncoding("UTF-8");
|
|
||||||
characterEncodingIPFilter.setForceEncoding(true);
|
|
||||||
servletContext.addFilter("encodingFilter", characterEncodingIPFilter).addMappingForUrlPatterns(null, false, "/*");
|
|
||||||
|
|
||||||
DelegatingFilterProxy securityFilter = new DelegatingFilterProxy("springSecurityFilterChain");
|
|
||||||
servletContext.addFilter("springSecurityFilterChain", securityFilter).addMappingForUrlPatterns(null, false, "/*");
|
|
||||||
|
|
||||||
// SiteMeshFilter siteMeshFilter = new SiteMeshFilter();
|
|
||||||
// servletContext.addFilter("sitemesh", siteMeshFilter).addMappingForUrlPatterns(null, false, "/*");
|
|
||||||
|
|
||||||
//Add Listeners
|
|
||||||
|
|
||||||
servletContext.addListener(Log4jConfigListener.class);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// protected WebApplicationContext createRootApplicationContext() {
|
|
||||||
// return createServletApplicationContext();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// protected WebApplicationContext createServletApplicationContext() {
|
|
||||||
// AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
|
|
||||||
// context.scan(ClassUtils.getPackageName(getClass()));
|
|
||||||
// return context;
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Class<?>[] getRootConfigClasses() {
|
|
||||||
return new Class[]{ContextConfigurer.class, WebSecurityConfigurer.class, OAuth2ServerConfig.class};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Class<?>[] getServletConfigClasses() {
|
|
||||||
return new Class[]{WebMvcConfigurer.class};
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,42 +0,0 @@
|
||||||
package com.monkeyk.sos.config;
|
|
||||||
|
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.web.servlet.config.annotation.*;
|
|
||||||
import org.springframework.web.servlet.view.InternalResourceViewResolver;
|
|
||||||
import org.springframework.web.servlet.view.JstlView;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 2016/4/3
|
|
||||||
* <p/>
|
|
||||||
* Replace mkk-servlet.xml
|
|
||||||
*
|
|
||||||
* @author Shengzhao Li
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
@EnableWebMvc
|
|
||||||
@ComponentScan(basePackages = {"com.monkeyk.sos.web"})
|
|
||||||
public class WebMvcConfigurer extends WebMvcConfigurerAdapter {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
|
|
||||||
configurer.enable();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void configureViewResolvers(ViewResolverRegistry registry) {
|
|
||||||
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
|
|
||||||
viewResolver.setViewClass(JstlView.class);
|
|
||||||
viewResolver.setPrefix("/WEB-INF/jsp/");
|
|
||||||
viewResolver.setSuffix(".jsp");
|
|
||||||
registry.viewResolver(viewResolver);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
|
||||||
registry.addResourceHandler("/index.jsp*").addResourceLocations("/index.jsp");
|
|
||||||
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -65,11 +65,7 @@ public class WebSecurityConfigurer extends WebSecurityConfigurerAdapter {
|
||||||
web.expressionHandler(new OAuth2WebSecurityExpressionHandler());
|
web.expressionHandler(new OAuth2WebSecurityExpressionHandler());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@Bean(name = "authenticationManager")
|
|
||||||
public AuthenticationManager authenticationManagerBean() throws Exception {
|
|
||||||
return super.authenticationManagerBean();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -8,5 +8,19 @@ spring.datasource.driver-class-name=com.mysql.jdbc.Driver
|
||||||
spring.datasource.url=jdbc:mysql://localhost:3306/oauth2?autoReconnect=true&autoReconnectForPools=true&useUnicode=true&characterEncoding=utf8
|
spring.datasource.url=jdbc:mysql://localhost:3306/oauth2?autoReconnect=true&autoReconnectForPools=true&useUnicode=true&characterEncoding=utf8
|
||||||
spring.datasource.data-username=andaily
|
spring.datasource.data-username=andaily
|
||||||
spring.datasource.data-password=andaily
|
spring.datasource.data-password=andaily
|
||||||
|
#
|
||||||
|
#THYMELEAF
|
||||||
|
#
|
||||||
|
spring.thymeleaf.prefix=/WEB-INF/view/
|
||||||
|
spring.thymeleaf.suffix=.html
|
||||||
|
spring.thymeleaf.mode=HTML5
|
||||||
|
spring.thymeleaf.encoding=UTF-8
|
||||||
|
# ;charset=<encoding> is added
|
||||||
|
spring.thymeleaf.content-type=text/html
|
||||||
|
# set to false for hot refresh
|
||||||
|
spring.thymeleaf.cache=false
|
||||||
|
#
|
||||||
|
# Logging
|
||||||
|
#
|
||||||
|
logging.level.root=INFO
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue