mirror of
https://github.com/hs-web/hsweb-framework.git
synced 2026-05-14 01:16:07 +08:00
优化配置
This commit is contained in:
Binary file not shown.
@@ -1,14 +1,15 @@
|
||||
package org.hswebframework.web;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author zhouhao
|
||||
* @since 2.0
|
||||
*/
|
||||
@Component
|
||||
public class ApplicationContextHolder {
|
||||
public class ApplicationContextHolder implements ApplicationContextAware {
|
||||
private static ApplicationContext context;
|
||||
|
||||
public static ApplicationContext get() {
|
||||
@@ -18,10 +19,10 @@ public class ApplicationContextHolder {
|
||||
return context;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setContext(ApplicationContext context) {
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) {
|
||||
if (null == ApplicationContextHolder.context) {
|
||||
ApplicationContextHolder.context = context;
|
||||
ApplicationContextHolder.context = applicationContext;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,12 +24,12 @@ import com.alibaba.fastjson.parser.ParserConfig;
|
||||
import com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer;
|
||||
import com.alibaba.fastjson.parser.deserializer.ObjectDeserializer;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import org.hswebframework.web.ApplicationContextHolder;
|
||||
import org.hswebframework.web.ThreadLocalUtils;
|
||||
import org.hswebframework.web.bean.FastBeanCopier;
|
||||
import org.hswebframework.web.commons.entity.factory.EntityFactory;
|
||||
import org.hswebframework.web.commons.entity.factory.MapperEntityFactory;
|
||||
import org.hswebframework.web.convert.CustomMessageConverter;
|
||||
import org.hswebframework.web.dict.EnumDict;
|
||||
import org.hswebframework.web.service.DefaultLogicPrimaryKeyValidator;
|
||||
import org.hswebframework.web.starter.convert.FastJsonGenericHttpMessageConverter;
|
||||
import org.hswebframework.web.starter.convert.FastJsonHttpMessageConverter;
|
||||
@@ -47,7 +47,6 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
||||
@@ -59,9 +58,6 @@ import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.sql.DataSource;
|
||||
import javax.validation.Validation;
|
||||
import javax.validation.Validator;
|
||||
import javax.validation.ValidatorFactory;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.List;
|
||||
@@ -70,7 +66,6 @@ import java.util.List;
|
||||
* @author zhouhao
|
||||
*/
|
||||
@Configuration
|
||||
//@ComponentScan("org.hswebframework.web")
|
||||
@EnableConfigurationProperties(EntityProperties.class)
|
||||
@ImportAutoConfiguration(EntityFactoryInitConfiguration.class)
|
||||
public class HswebAutoConfiguration {
|
||||
@@ -203,6 +198,11 @@ public class HswebAutoConfiguration {
|
||||
}
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ApplicationContextHolder applicationContextHolder() {
|
||||
return new ApplicationContextHolder();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RestControllerExceptionTranslator restControllerExceptionTranslator() {
|
||||
return new RestControllerExceptionTranslator();
|
||||
|
||||
Reference in New Issue
Block a user