org.zodiac.autoconfigure.web.ServletWebAutoConfiguration Maven / Gradle / Ivy
package org.zodiac.autoconfigure.web;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
import org.zodiac.commons.excel.ExcelOperations;
import org.zodiac.commons.excel.ServletExcelTemplate;
@SpringBootConfiguration
@ConditionalOnWebApplication(type = Type.SERVLET)
@ConditionalOnClass(value = {javax.servlet.Servlet.class, org.springframework.web.servlet.DispatcherServlet.class})
public class ServletWebAutoConfiguration {
private RequestMappingHandlerAdapter requestMappingHandlerAdapter;
private RequestMappingHandlerMapping requestMappingHandlerMapping;
public ServletWebAutoConfiguration(
@Qualifier(value = "requestMappingHandlerAdapter") @Autowired(required = false) RequestMappingHandlerAdapter requestMappingHandlerAdapterProvider,
@Qualifier(value = "requestMappingHandlerMapping") @Autowired(required = false) RequestMappingHandlerMapping requestMappingHandlerMappingProvider) {
this.requestMappingHandlerAdapter = requestMappingHandlerAdapterProvider;
this.requestMappingHandlerMapping = requestMappingHandlerMappingProvider;
}
@Bean
@ConditionalOnMissingBean
@ConditionalOnClass
protected org.zodiac.core.web.WebOperations webOperations() {
return new org.zodiac.core.web.servlet.ServletWebTemplate();
}
@Bean
@ConditionalOnMissingBean
@ConditionalOnClass(name = {"com.alibaba.excel.write.handler.WriteHandler"})
protected ExcelOperations excelOperations() {
return new ServletExcelTemplate();
}
}