Integration of spring boot 2. X development case Quartz task management system

Keywords: Java Spring Hibernate Thymeleaf Database

CRUD task management system based on spring boot 2. X + quartz is suitable for small and medium-sized projects.

CRUD task management system based on spring boot + quartz:

https://gitee.com/52itstyle/spring-boot-quartz

development environment

JDK1.8,Maven,Eclipse

Technology stack

SpringBoot2.0.1,thymeleaf3.0.9,quartz2.3.0,iview,vue,layer,AdminLTE,bootstrap

Startup instructions

  • The database used by the project is MySql. Select the tables > MySql > innodb.sql file in resources/sql to initialize the database information.
  • Replace with your own data source in the resources/application.properties file.
  • Run the Application main method to start the project, which will automatically create a test task. See com.itstype.quartz.config.taskrunner.java.
  • Project access address: http://localhost:8080/task

Project screenshots






Project source code: https://gitee.com/52itstyle/spring-boot-task

Version difference (spring boot 1. X and 2. X)

This is just a comparison of the similarities and differences between the two projects. Of course, there are still many things to be noticed in the spring boot 2. X version upgrade.

Project name configuration:

# spring boot 1.x
server.context-path=/quartz
# spring boot 2.x
server.servlet.context-path=/quartz

thymeleaf configuration:

#spring boot 1.x
spring.thymeleaf.mode=LEGACYHTML5
#spring boot 2.x
spring.thymeleaf.mode=HTML

Hibernate configuration:

# spring boot 2.x JPA relies on Hibernate 5
# Hibernate 4 naming strategy fully qualified name. Not supported with Hibernate 5.
spring.jpa.hibernate.naming.strategy = org.hibernate.cfg.ImprovedNamingStrategy
# stripped before adding them to the entity manager)
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
# Hibernate 5
spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl

quartz configuration:

# spring boot 2.x is integrated with Quartz and does not need to be configured by yourself
spring.quartz.job-store-type=jdbc
spring.quartz.properties.org.quartz.scheduler.instanceName=clusteredScheduler
spring.quartz.properties.org.quartz.scheduler.instanceId=AUTO
spring.quartz.properties.org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTX
spring.quartz.properties.org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegate
spring.quartz.properties.org.quartz.jobStore.tablePrefix=QRTZ_
spring.quartz.properties.org.quartz.jobStore.isClustered=true
spring.quartz.properties.org.quartz.jobStore.clusterCheckinInterval=10000
spring.quartz.properties.org.quartz.jobStore.useProperties=false
spring.quartz.properties.org.quartz.threadPool.class=org.quartz.simpl.SimpleThreadPool
spring.quartz.properties.org.quartz.threadPool.threadCount=10
spring.quartz.properties.org.quartz.threadPool.threadPriority=5
spring.quartz.properties.org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread=true

Default home page configuration:

/**
 * Configure homepage spring boot 1.x
 * Creator Xiaoqi 2012
 * Created on September 7, 2017
 */
@Configuration
public class MyAdapter extends WebMvcConfigurerAdapter{
    @Override
    public void addViewControllers( ViewControllerRegistry registry ) {
        registry.addViewController( "/" ).setViewName( "forward:/login.shtml" );
        registry.setOrder( Ordered.HIGHEST_PRECEDENCE );
        super.addViewControllers( registry );
    } 
}
/**
 * Configure the home page (in spring boot 2.0 and Spring 5.0 WebMvcConfigurerAdapter to be discarded 
 * It is recommended to implement the WebMvcConfigurer interface)
 * Creator Xiaoqi 2012
 * Created on April 10, 2018
 */
@Configuration
public class MyAdapter implements WebMvcConfigurer{
    @Override
    public void addViewControllers( ViewControllerRegistry registry ) {
        registry.addViewController( "/" ).setViewName( "forward:/login.shtml" );
        registry.setOrder( Ordered.HIGHEST_PRECEDENCE );
    } 
}

Problems to be solved:

/**
     * Set a strategy for handling the query results. This can be used to change
     * "shape" of the query result.
     *
     * @param transformer The transformer to apply
     *
     * @return this (for method chaining)
     *
     * @deprecated (since 5.2)
     * @todo develop a new approach to result transformers
     */
    @Deprecated
    Query<R> setResultTransformer(ResultTransformer transformer);

hibernate 5.2 abandons setResultTransformer, saying that it is to develop a new method to obtain sets. Obviously, it has not been implemented yet and is in TODO state.

Project source code: https://gitee.com/52itstyle/spring-boot-task

Posted by deception54 on Fri, 03 Apr 2020 04:17:34 -0700