spring boot 升级到2.0.1
This commit is contained in:
parent
d659601961
commit
a3a8bc140e
|
@ -21,11 +21,6 @@
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- actviti begin-->
|
<!-- actviti begin-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.activiti</groupId>
|
<groupId>org.activiti</groupId>
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
package com.len.exception;
|
||||||
|
|
||||||
|
import org.springframework.boot.autoconfigure.web.servlet.error.ErrorViewResolver;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zhuxiaomeng
|
||||||
|
* @date 2018/5/6.
|
||||||
|
* @email 154040976@qq.com
|
||||||
|
*/
|
||||||
|
@ControllerAdvice
|
||||||
|
public class CustomErrorViewResolver implements ErrorViewResolver {
|
||||||
|
|
||||||
|
static final String PAGE_500 = "/error/500";
|
||||||
|
static final String PAGE_404 = "/error/404";
|
||||||
|
static final String PAGE_403 = "/error/403";
|
||||||
|
static final String OTHER_ERROR = "/error/error";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ModelAndView resolveErrorView(HttpServletRequest request,
|
||||||
|
HttpStatus status, Map<String, Object> model) {
|
||||||
|
boolean isServerError = status.is5xxServerError();
|
||||||
|
ModelAndView andView = new ModelAndView();
|
||||||
|
andView.addObject("message", model.get("message"));
|
||||||
|
|
||||||
|
if ("404".equals(status.value())) {
|
||||||
|
andView.setViewName(PAGE_404);
|
||||||
|
} else if ("403".equals(status.value())) {
|
||||||
|
andView.setViewName(PAGE_403);
|
||||||
|
} else if (isServerError) {
|
||||||
|
andView.setViewName(PAGE_500);
|
||||||
|
} else {
|
||||||
|
andView.addObject("status", status.value());
|
||||||
|
andView.setViewName(OTHER_ERROR);
|
||||||
|
}
|
||||||
|
return andView;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,2 @@
|
||||||
|
<h2>500</h2>
|
||||||
|
<h2>原因:${message}</h2>
|
|
@ -1 +1,2 @@
|
||||||
|
<h2>${status}</h2>
|
||||||
<h1>${message}</h1>
|
<h1>${message}</h1>
|
|
@ -2,6 +2,7 @@ package com.len;
|
||||||
|
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
@ -21,6 +22,9 @@ import java.util.Arrays;
|
||||||
@EnableTransactionManagement
|
@EnableTransactionManagement
|
||||||
@ComponentScan({"com.len","org.activiti"})
|
@ComponentScan({"com.len","org.activiti"})
|
||||||
@MapperScan(basePackages = {"com.len.mapper"})
|
@MapperScan(basePackages = {"com.len.mapper"})
|
||||||
|
@EnableAutoConfiguration(exclude = {
|
||||||
|
org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class
|
||||||
|
})
|
||||||
public class Application {
|
public class Application {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
|
@ -1,20 +1,15 @@
|
||||||
package com.len.config;
|
package com.len.config;
|
||||||
|
|
||||||
import com.jagregory.shiro.freemarker.ShiroTags;
|
|
||||||
import freemarker.template.TemplateException;
|
import freemarker.template.TemplateException;
|
||||||
import freemarker.template.TemplateModelException;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Properties;
|
|
||||||
import javax.annotation.PostConstruct;
|
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.ui.freemarker.FreeMarkerConfigurationFactory;
|
import org.springframework.ui.freemarker.FreeMarkerConfigurationFactory;
|
||||||
import org.springframework.web.servlet.ViewResolver;
|
import org.springframework.web.servlet.ViewResolver;
|
||||||
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
|
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
|
||||||
import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;
|
import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Properties;
|
||||||
/**
|
/**
|
||||||
* @author zhuxiaomeng
|
* @author zhuxiaomeng
|
||||||
* @date 2018/1/2.
|
* @date 2018/1/2.
|
||||||
|
@ -33,7 +28,7 @@ public class FreeMarkerConfig{
|
||||||
resolver.setExposeRequestAttributes(true);
|
resolver.setExposeRequestAttributes(true);
|
||||||
resolver.setExposeSessionAttributes(true);
|
resolver.setExposeSessionAttributes(true);
|
||||||
resolver.setSuffix(".ftl");
|
resolver.setSuffix(".ftl");
|
||||||
resolver.setContentType("text/html; charset=UTF-8");
|
resolver.setContentType("text/html;charset=UTF-8");
|
||||||
resolver.setOrder(0);
|
resolver.setOrder(0);
|
||||||
return resolver;
|
return resolver;
|
||||||
}
|
}
|
||||||
|
@ -48,7 +43,7 @@ public class FreeMarkerConfig{
|
||||||
resolver.setExposeSessionAttributes(true);
|
resolver.setExposeSessionAttributes(true);
|
||||||
resolver.setOrder(1);
|
resolver.setOrder(1);
|
||||||
resolver.setSuffix(".html");
|
resolver.setSuffix(".html");
|
||||||
resolver.setContentType("text/html; charset=UTF-8");
|
resolver.setContentType("text/html;charset=UTF-8");
|
||||||
return resolver;
|
return resolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,7 @@ import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.http.converter.HttpMessageConverter;
|
import org.springframework.http.converter.HttpMessageConverter;
|
||||||
import org.springframework.http.converter.StringHttpMessageConverter;
|
import org.springframework.http.converter.StringHttpMessageConverter;
|
||||||
import org.springframework.web.servlet.LocaleResolver;
|
import org.springframework.web.servlet.LocaleResolver;
|
||||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
import org.springframework.web.servlet.config.annotation.*;
|
||||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
|
||||||
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
|
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
|
||||||
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
|
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
|
||||||
|
|
||||||
|
@ -23,7 +21,7 @@ import java.util.Locale;
|
||||||
* spring shiro
|
* spring shiro
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
public class WebMvcConfig extends WebMvcConfigurerAdapter {
|
public class WebMvcConfig extends WebMvcConfigurationSupport {
|
||||||
|
|
||||||
@Value("${imagePath}")
|
@Value("${imagePath}")
|
||||||
private String imagePath;
|
private String imagePath;
|
||||||
|
|
19
pom.xml
19
pom.xml
|
@ -11,7 +11,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<version>1.5.9.RELEASE</version>
|
<version>2.0.1.RELEASE</version>
|
||||||
<relativePath />
|
<relativePath />
|
||||||
</parent>
|
</parent>
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -29,6 +29,15 @@
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
|
<!--<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-properties-migrator</artifactId>
|
||||||
|
</dependency>-->
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
@ -107,12 +116,12 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.pagehelper</groupId>
|
<groupId>com.github.pagehelper</groupId>
|
||||||
<artifactId>pagehelper-spring-boot-autoconfigure</artifactId>
|
<artifactId>pagehelper-spring-boot-autoconfigure</artifactId>
|
||||||
<version>1.2.3</version>
|
<version>1.2.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.pagehelper</groupId>
|
<groupId>com.github.pagehelper</groupId>
|
||||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||||
<version>1.2.3</version>
|
<version>1.2.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -305,11 +314,11 @@
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<!-- <dependency>
|
||||||
<groupId>de.codecentric</groupId>
|
<groupId>de.codecentric</groupId>
|
||||||
<artifactId>spring-boot-admin-starter-client</artifactId>
|
<artifactId>spring-boot-admin-starter-client</artifactId>
|
||||||
<version>1.5.7</version>
|
<version>1.5.7</version>
|
||||||
</dependency>
|
</dependency>-->
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
Loading…
Reference in New Issue