Browse Source

upgrade spring-boot to 2.1.x and spring to 5.x

pull/2/head
chgxtony 6 years ago
parent
commit
958556e61b
  1. 4
      escheduler-alert/pom.xml
  2. 11
      escheduler-api/pom.xml
  3. 7
      escheduler-api/src/main/java/cn/escheduler/api/configuration/AppConfiguration.java
  4. 4
      escheduler-common/pom.xml
  5. 77
      escheduler-common/src/main/java/cn/escheduler/common/utils/DateUtils.java
  6. 1
      escheduler-server/src/main/java/cn/escheduler/server/master/MasterServer.java
  7. 84
      pom.xml

4
escheduler-alert/pom.xml

@ -90,10 +90,6 @@
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
</dependency>
<!--excel poi--> <!--excel poi-->
<dependency> <dependency>

11
escheduler-api/pom.xml

@ -38,13 +38,6 @@
</dependency> </dependency>
<!--springboot--> <!--springboot-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>${spring.boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
@ -54,10 +47,6 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId> <artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion> </exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</exclusion>
</exclusions> </exclusions>
</dependency> </dependency>

7
escheduler-api/src/main/java/cn/escheduler/api/configuration/AppConfiguration.java

@ -19,16 +19,13 @@ package cn.escheduler.api.configuration;
import cn.escheduler.api.interceptor.LoginHandlerInterceptor; import cn.escheduler.api.interceptor.LoginHandlerInterceptor;
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.web.servlet.config.annotation.ContentNegotiationConfigurer; import org.springframework.web.servlet.config.annotation.*;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
/** /**
* application configuration * application configuration
*/ */
@Configuration @Configuration
public class AppConfiguration extends WebMvcConfigurerAdapter { public class AppConfiguration implements WebMvcConfigurer {
public static final String LOGIN_INTERCEPTOR_PATH_PATTERN = "/**/*"; public static final String LOGIN_INTERCEPTOR_PATH_PATTERN = "/**/*";
public static final String LOGIN_PATH_PATTERN = "/login"; public static final String LOGIN_PATH_PATTERN = "/login";

4
escheduler-common/pom.xml

@ -240,10 +240,6 @@
<artifactId>postgresql</artifactId> <artifactId>postgresql</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.apache.hive</groupId> <groupId>org.apache.hive</groupId>
<artifactId>hive-jdbc</artifactId> <artifactId>hive-jdbc</artifactId>

77
escheduler-common/src/main/java/cn/escheduler/common/utils/DateUtils.java

@ -20,8 +20,10 @@ import cn.escheduler.common.Constants;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.text.ParseException; import java.time.Instant;
import java.text.SimpleDateFormat; import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
@ -32,6 +34,27 @@ public class DateUtils {
private static final Logger logger = LoggerFactory.getLogger(DateUtils.class); private static final Logger logger = LoggerFactory.getLogger(DateUtils.class);
/**
* <code>java.util.Date</code> to <code>java.time.LocalDateTime</code>
* use default zone
* @param date
* @return
*/
private static LocalDateTime date2LocalDateTime(Date date) {
return LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
}
/**
* <code>java.time.LocalDateTime</code> to <code>java.util.Date</code>
* use default zone
* @param localDateTime
* @return
*/
private static Date localDateTime2Date(LocalDateTime localDateTime) {
Instant instant = localDateTime.atZone(ZoneId.systemDefault()).toInstant();
return Date.from(instant);
}
/** /**
* @return get the formatted date string for the current time * @return get the formatted date string for the current time
*/ */
@ -44,7 +67,8 @@ public class DateUtils {
* @return get the date string in the specified format of the current time * @return get the date string in the specified format of the current time
*/ */
public static String getCurrentTime(String format) { public static String getCurrentTime(String format) {
return new SimpleDateFormat(format).format(new Date()); // return new SimpleDateFormat(format).format(new Date());
return LocalDateTime.now().format(DateTimeFormatter.ofPattern(format));
} }
/** /**
@ -53,15 +77,25 @@ public class DateUtils {
* @return get the formatted date string * @return get the formatted date string
*/ */
public static String format(Date date, String format) { public static String format(Date date, String format) {
return new SimpleDateFormat(format).format(date); // return new SimpleDateFormat(format).format(date);
return format(date2LocalDateTime(date), format);
}
/**
* @param localDateTime
* @param format e.g. yyyy-MM-dd HH:mm:ss
* @return get the formatted date string
*/
public static String format(LocalDateTime localDateTime, String format) {
return localDateTime.format(DateTimeFormatter.ofPattern(format));
} }
/** /**
* @param date * @param date
* @return convert time to yyyy-MM-dd HH:mm:ss format * @return convert time to yyyy-MM-dd HH:mm:ss format
*/ */
public static String dateToString(Date date){ public static String dateToString(Date date) {
return format(date,Constants.YYYY_MM_DD_HH_MM_SS); return format(date, Constants.YYYY_MM_DD_HH_MM_SS);
} }
@ -69,9 +103,11 @@ public class DateUtils {
* @param date * @param date
* @return convert string to date and time * @return convert string to date and time
*/ */
public static Date parse(String date,String format){ public static Date parse(String date, String format) {
try { try {
return new SimpleDateFormat(format).parse(date); // return new SimpleDateFormat(format).parse(date);
LocalDateTime ldt = LocalDateTime.parse(date, DateTimeFormatter.ofPattern(format));
return localDateTime2Date(ldt);
} catch (Exception e) { } catch (Exception e) {
logger.error("error while parse date:" + date, e); logger.error("error while parse date:" + date, e);
} }
@ -80,11 +116,12 @@ public class DateUtils {
/** /**
* convert date str to yyyy-MM-dd HH:mm:ss format * convert date str to yyyy-MM-dd HH:mm:ss format
*
* @param str * @param str
* @return * @return
*/ */
public static Date stringToDate(String str){ public static Date stringToDate(String str) {
return parse(str,Constants.YYYY_MM_DD_HH_MM_SS); return parse(str, Constants.YYYY_MM_DD_HH_MM_SS);
} }
/** /**
@ -135,6 +172,7 @@ public class DateUtils {
/** /**
* get the date of the specified date in the days before and after * get the date of the specified date in the days before and after
*
* @param date * @param date
* @param day * @param day
* @return * @return
@ -159,10 +197,11 @@ public class DateUtils {
/** /**
* convert schedule string to date * convert schedule string to date
*
* @param schedule * @param schedule
* @return * @return
*/ */
public static Date getScheduleDate(String schedule){ public static Date getScheduleDate(String schedule) {
return stringToDate(schedule); return stringToDate(schedule);
} }
@ -185,7 +224,7 @@ public class DateUtils {
/** /**
* get monday * get monday
* * <p>
* note: Set the first day of the week to Monday, the default is Sunday * note: Set the first day of the week to Monday, the default is Sunday
*/ */
public static Date getMonday(Date date) { public static Date getMonday(Date date) {
@ -201,7 +240,7 @@ public class DateUtils {
/** /**
* get sunday * get sunday
* * <p>
* note: Set the first day of the week to Monday, the default is Sunday * note: Set the first day of the week to Monday, the default is Sunday
*/ */
public static Date getSunday(Date date) { public static Date getSunday(Date date) {
@ -257,10 +296,11 @@ public class DateUtils {
/** /**
* return YYYY-MM-DD 00:00:00 * return YYYY-MM-DD 00:00:00
*
* @param inputDay * @param inputDay
* @return * @return
*/ */
public static Date getStartOfDay(Date inputDay){ public static Date getStartOfDay(Date inputDay) {
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
cal.setTime(inputDay); cal.setTime(inputDay);
cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.HOUR_OF_DAY, 0);
@ -271,10 +311,11 @@ public class DateUtils {
/** /**
* return YYYY-MM-DD 23:59:59 * return YYYY-MM-DD 23:59:59
*
* @param inputDay * @param inputDay
* @return * @return
*/ */
public static Date getEndOfDay(Date inputDay){ public static Date getEndOfDay(Date inputDay) {
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
cal.setTime(inputDay); cal.setTime(inputDay);
cal.set(Calendar.HOUR_OF_DAY, 23); cal.set(Calendar.HOUR_OF_DAY, 23);
@ -285,10 +326,11 @@ public class DateUtils {
/** /**
* return YYYY-MM-DD 00:00:00 * return YYYY-MM-DD 00:00:00
*
* @param inputDay * @param inputDay
* @return * @return
*/ */
public static Date getStartOfHour(Date inputDay){ public static Date getStartOfHour(Date inputDay) {
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
cal.setTime(inputDay); cal.setTime(inputDay);
cal.set(Calendar.MINUTE, 0); cal.set(Calendar.MINUTE, 0);
@ -298,10 +340,11 @@ public class DateUtils {
/** /**
* return YYYY-MM-DD 23:59:59 * return YYYY-MM-DD 23:59:59
*
* @param inputDay * @param inputDay
* @return * @return
*/ */
public static Date getEndOfHour(Date inputDay){ public static Date getEndOfHour(Date inputDay) {
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
cal.setTime(inputDay); cal.setTime(inputDay);
cal.set(Calendar.MINUTE, 59); cal.set(Calendar.MINUTE, 59);

1
escheduler-server/src/main/java/cn/escheduler/server/master/MasterServer.java

@ -189,7 +189,6 @@ public class MasterServer implements CommandLineRunner, IStoppable {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication app = new SpringApplication(MasterServer.class); SpringApplication app = new SpringApplication(MasterServer.class);
app.setWebEnvironment(false);
app.run(args); app.run(args);
} }

84
pom.xml

@ -8,12 +8,13 @@
<name>escheduler</name> <name>escheduler</name>
<url>http://maven.apache.org</url> <url>http://maven.apache.org</url>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<curator.version>2.12.0</curator.version> <curator.version>2.12.0</curator.version>
<spring.version>4.3.7.RELEASE</spring.version> <spring.version>5.1.5.RELEASE</spring.version>
<spring.boot.version>1.4.5.RELEASE</spring.boot.version> <spring.boot.version>2.1.3.RELEASE</spring.boot.version>
<java.version>1.8</java.version> <java.version>1.8</java.version>
<logback.version>1.2.3</logback.version> <logback.version>1.2.3</logback.version>
<hadoop.version>2.7.3</hadoop.version> <hadoop.version>2.7.3</hadoop.version>
@ -23,16 +24,27 @@
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.5.1</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>2.0.1</version>
</dependency>
<dependency> <dependency>
<groupId>org.mybatis.spring.boot</groupId> <groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-autoconfigure</artifactId> <artifactId>mybatis-spring-boot-autoconfigure</artifactId>
<version>1.2.0</version> <version>2.0.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mybatis.spring.boot</groupId> <groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId> <artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.2.0</version> <version>2.0.1</version>
</dependency> </dependency>
<!-- quartz--> <!-- quartz-->
<dependency> <dependency>
<groupId>org.quartz-scheduler</groupId> <groupId>org.quartz-scheduler</groupId>
@ -49,36 +61,26 @@
<artifactId>cron-utils</artifactId> <artifactId>cron-utils</artifactId>
<version>5.0.5</version> <version>5.0.5</version>
</dependency> </dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.4.2</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency> <dependency>
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId> <artifactId>fastjson</artifactId>
<version>1.2.29</version> <version>1.2.29</version>
</dependency> </dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.14</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>${spring.boot.version}</version> <version>${spring.boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId> <artifactId>spring-core</artifactId>
@ -96,31 +98,21 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId> <artifactId>spring-tx</artifactId>
<version>${spring.version}</version> <version>${spring.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-jdbc</artifactId>
<version>${spring.boot.version}</version> <version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring.boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>${spring.boot.version}</version>
<scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-boot-starter-aop</artifactId> <artifactId>spring-test</artifactId>
<version>${spring.boot.version}</version> <version>${spring.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>cn.analysys</groupId> <groupId>cn.analysys</groupId>
<artifactId>escheduler-common</artifactId> <artifactId>escheduler-common</artifactId>
@ -146,6 +138,7 @@
<artifactId>escheduler-alert</artifactId> <artifactId>escheduler-alert</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.curator</groupId> <groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId> <artifactId>curator-framework</artifactId>
@ -249,11 +242,6 @@
</dependency> </dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.14</version>
</dependency>
<dependency> <dependency>
<groupId>ch.qos.logback</groupId> <groupId>ch.qos.logback</groupId>

Loading…
Cancel
Save