@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})

@SpringBootApplication(exclude = DataSourceAutoConfiguration.class) 的 作用是  :取消数据库配置。
package com.xxx.ucf.mdf;

import com.xxx.diwork.config.DiworkEnv;
import com.xxx.diwork.filter.DiworkRequestListener;
import com.xxx.iuap.ucf.log.filter.MDCLogFilter;
import com.xxx.ucf.mdd.common.interfaces.context.IAppContextTransfer;
import com.xxx.ucf.mdd.load.MddBaseContext;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.context.annotation.ImportResource;
import org.springframework.security.web.firewall.HttpFirewall;
import org.springframework.security.web.firewall.StrictHttpFirewall;


/**
 * spring-boot 入口类
 */
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
@ComponentScan(basePackages = {"com.xxx", "com.xxxcloud"}, excludeFilters = {@ComponentScan.Filter(type = FilterType.REGEX, pattern = { "com.xxxcloud.uretail.controller.*","com.xxxcloud.uretail.*.controller.*","com.xxxcloud.uretail.util.file.oss.AliOss"})})
@ImportResource({DiworkEnv.DIWORK_CONFIG_XML})
public class MDFApplication {

    public static void main(String[] args) {
        //System.setProperty("mddRpcType", "dubbo");
        ApplicationContext app = SpringApplication.run(MDFApplication.class, args);
    }

    /**
     * 配置请求上下文拦截器
     */
    @Bean
    public FilterRegistrationBean RequestListener() {
        FilterRegistrationBean registrationBean = new FilterRegistrationBean();
        registrationBean.setFilter(new DiworkRequestListener());
        registrationBean.addUrlPatterns("/*");
        registrationBean.addInitParameter("excludedPages", "/pub/fileupload/download,/bpm/complete,/bpm/registerInterface,/bpm/testConn");
        return registrationBean;
    }

    @Bean
    public HttpFirewall allowUrlEncodedSlashHttpFirewall() {
        StrictHttpFirewall firewall = new StrictHttpFirewall();
        firewall.setAllowUrlEncodedSlash(true);
        return firewall;
    }

    /**
     * ucf-log 日志接入
     * @return
     */
   @Bean
   public FilterRegistrationBean LogFilter() {
      FilterRegistrationBean registrationBean = new FilterRegistrationBean();
      registrationBean.setFilter(new MDCLogFilter());
      registrationBean.addUrlPatterns("/*");
      return registrationBean;
   }

}

你可能感兴趣的:(SpringBoot)