1、创建maven项目
默认下一步
由于只是创建一个demo用于启动,所以选择maven-archetype-quickstart,(创建web项目可以选择maven-archetype-webapp),后续步骤都是一样的。
填写Group Id和Artifact Id,该信息仅用于本demo,无其他影响,可随意填写。
修改项目的目录结构
修改JDK配置
修改编译环境配置,适配自己使用的jdk版本
项目创建成功后,结构如图:
注:创建之后可能会在项目文件夹上出现红叉,但是又没有报错。该问题,可以参考另一篇文章解决。
eclipse新建maven项目,项目无报错,但是有红叉
2、maven集成springboot
(1)修改pom文件
4.0.0 quartz quartzDemo 0.0.1-SNAPSHOT jar quartzDemo http://maven.apache.org UTF-8 UTF-8 1.8 ${java.version} ${java.version} org.springframework.boot spring-boot-starter-parent 2.2.5.RELEASE org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-aop org.mybatis.spring.boot mybatis-spring-boot-starter 1.2.0 org.springframework.boot spring-boot-starter-test test org.apache.commons commons-lang3 3.4 com.alibaba fastjson 1.2.75 org.springframework.boot spring-boot-maven-plugin true
修改后记得maven update一下,否则会报错,报错如下图。
3、controller类
package com.Controller;
import java.util.List;
import javax.annotation.Resource;
import org.apache.ibatis.annotations.Param;
import org.quartz.SchedulerException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import com.service.TaskService;
import com.utils.QuartzManager;
@RestController
public class TestController {
@GetMapping(value = "/test")
public String test() {
return "test";
}
}
3、创建springboot启动类
创建springboot启动类:SpringbootApplication.java
package com;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringbootApplication {
public static void main(String[] args) {
SpringApplication.run(SpringbootApplication.class, args);
}
}



