1. 程式人生 > >spring boot + spring batch+ quartz例項

spring boot + spring batch+ quartz例項

注:本文非基礎教學類文章

首先工程用到的主要jar包

spring-batch-core-3.0.0.jar

quartz-2.1.6.jar

(一) quartz實現  實際開發過程中系統中肯定有任務管理模組,所以就按實際開發來寫了
import com.alibaba.fastjson.TypeReference;
import org.apache.commons.lang.StringUtils;
import org.quartz.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.PostConstruct;
import java.text.ParseException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 定時job操作service
 *
 * @author
 * @create 2017年4月10日
 */
//@Service(version = "2.0",group = "",timeout = 3000000)
@Transactional
@SuppressWarnings("rawtypes")
public class JobService {


    @Autowired
    private QrtzTriggersMapper qrtzTriggersMapper;//任務DAO

    @Autowired
    private Scheduler scheduler;//定時器

    /**
     * 初始化執行排程任務
     */
    @PostConstruct
    public void initScheduler() {
        try {
            scheduler.start();
        } catch (SchedulerException e) {
            log.error("初始化排程任務失敗:", e);
        }
    }



    /**
     * 獲取job列表
     *
     * @param page
     * @return
     */
    @Override
    public String loadSchedulers(Map<String,Object> map) {
        Page<QrtzJobDetails> page = new Page<>(Integer.parseInt(map.get("row").toString()),
                Integer.parseInt(map.get("page").toString()));
        map.put("offset",page.getOffset());
        map.put("pageSize",page.getPageSize());
        List<QrtzJobDetails> list = schedulerJobMapper.loadSchedulers(map);
        int count = schedulerJobMapper.loadSchedulerCount(map);
        return JsonUtil.toJSONString(page.hold(list, count));
    }
 

    /**
     * 解析jobDetail引數
     *
     * @param qrtzJobDetails
     * @return
     */
    // 將引數放入map
    @SuppressWarnings("unchecked")
    public Map getJobParams(QrtzJobDetails qrtzJobDetails) {
        String classNamePath = null;
        if (StringUtils.isEmpty(qrtzJobDetails.getJobClassPath())) {
            classNamePath = "com.gomefinance.ecms.web.timer";// 任務類路徑 沒有選擇的預設到該路徑
        } else {
            classNamePath = qrtzJobDetails.getJobClassPath();
        }
        qrtzJobDetails.setJobClassName(classNamePath + "." + qrtzJobDetails.getJobClassName());
        Map parameterMap = new HashMap();
        String spitParamKey = "";
        String spitParamValue = "";
        String getParams[] = qrtzJobDetails.getParameterJson().replaceAll("\r|\n", "").split(";");
        if (qrtzJobDetails.getParameterJson().length() > 0) {
            for (String getParam : getParams) {
                spitParamKey = getParam;
                spitParamValue = getParam;
                int idx = spitParamKey.indexOf(",");
                spitParamKey = spitParamKey.substring(0, idx);
                int idx1 = spitParamValue.indexOf(",");
                spitParamValue = spitParamValue.substring(idx1 + 1, spitParamValue.length());
                parameterMap.put(spitParamKey.trim(), spitParamValue.trim());
            }
        }
        return parameterMap;
    }


    /**
     * 新增計劃
     *
     * @param param
     * @return
     */
    public String addControlTrigger(String param) {
        QrtzTriggers qrtzqTriggers = JsonUtil.toAny(param,new TypeReference<QrtzTriggers>(){});
        //驗證時間間隔不能為空
        if (",,,,,".equals(qrtzqTriggers.getTimeIntreval())) {
            return JsonUtil.toJSONString(new EntityWrapperResponse(EnumSystem.FAIL, "執行計劃的方式不能為空,請核對!"));
        }
        //查詢資料庫中 任務類名稱不能和計劃相同
        QrtzJobDetails qrtzJobDetails = schedulerJobMapper.loadSchedulerByName(qrtzqTriggers.getTriggerName());
        if (qrtzJobDetails != null) {
            return JsonUtil.toJSONString(new EntityWrapperResponse(EnumSystem.FAIL, "計劃名稱不能與任務名稱相同,請核對!"));
        }
        //一個任務相同計劃執行時間只能新增一次!TODO

        //計劃名稱不能重複
        QrtzTriggersKey qrtzTriggersKey = new QrtzTriggersKey(qrtzqTriggers.getSchedName(),
                qrtzqTriggers.getTriggerName(), qrtzqTriggers.getTriggerGroup());
        QrtzTriggers qrtz = qrtzTriggersMapper.selectByPrimaryKey(qrtzTriggersKey);
        if (qrtz != null) {
            return JsonUtil.toJSONString(new EntityWrapperResponse(EnumSystem.FAIL, qrtzqTriggers.getTriggerName() + ",計劃名稱已經存在,請核對!"));
        }
        //新增計劃
        this.addTrigger(qrtzqTriggers);
        return JsonUtil.toJSONString(new EntityWrapperResponse(EnumSystem.OK));
    }

    /**
     * 根據JObName獲取job
     * @param jobName
     * @return
     */
    @Override
    public QrtzJobDetails loadSchedulerByJobName(String jobName) {
        return schedulerJobMapper.loadSchedulerByName(jobName);
    }

    /**
     * 根據jobName獲取計劃列表
     * @param map
     * @return
     */
    @Override
    public String loadTrigger(Map<String,Object> map) {
        Page<QrtzTriggers> page = new Page<>(Integer.parseInt(map.get("row").toString()),
                Integer.parseInt(map.get("page").toString()));
        map.put("offset",page.getOffset());
        map.put("pageSize",page.getPageSize());
        List<QrtzTriggers> list = qrtzTriggersMapper.selectByJobName(page.getOffset(),page.getPageSize(),String.valueOf(map.get("jobName")));
        int count = qrtzTriggersMapper.selectCountByJobName(String.valueOf(map.get("jobName")));
        return JsonUtil.toJSONString(page.hold(list,count));
    }

    @SuppressWarnings("unchecked")
    public void addTrigger(QrtzTriggers qrtzqTriggers) {
        try {
            if (this.scheduler == null) {
                return;
            }
            String schedJobGroup = qrtzqTriggers.getJobGroup();//任務分組,後期維護到資料字典中。
            String schedTriggerGroup = qrtzqTriggers.getTriggerName();//觸發器分組,後期維護到資料字典中。
            JobKey jobKey = new JobKey(qrtzqTriggers.getJobName(), schedJobGroup);
            TriggerBuilder tb = TriggerBuilder.newTrigger();
            tb.withIdentity(qrtzqTriggers.getTriggerName(), schedTriggerGroup);

            // 構建triggerBuilder
            setTrigBuilder(qrtzqTriggers, tb);
            tb.forJob(jobKey);
            Trigger trig = tb.build();
            this.scheduler.start();
            this.scheduler.scheduleJob(trig);
        } catch (Exception e) {
            e.printStackTrace();
            throw new BusinessException("後臺有錯,錯誤【:" + e.getMessage() + "】,請檢查!");
        }

    }

    /***
     * 設定觸發器觸發時間*
     *
     * @param qrtzqTriggers
     * @param tb
     * @throws ParseException
     */
    private void setTrigBuilder(QrtzTriggers qrtzqTriggers, TriggerBuilder<Trigger> tb) throws ParseException {
        int type = Integer.parseInt(qrtzqTriggers.getTriggerType());
        String value[] = qrtzqTriggers.getTimeIntreval().split(",");
        switch (type) {
            case 1:
                //執行一次次
                excuteOnce(tb, value);
                break;
            case 2:
                //每天某分鐘執行
                everyDayMinute(tb, value);
                //this.addTrigger(qrtzqTriggers,Integer.parseInt(value[1]));
                break;
            case 3:
                //每天某小時某分執行
                everyDayHourMinue(tb, value);
                break;
            case 4:
                //某周某小時某分執行
                everyWeekHM(tb, value);
                break;
            case 5:
                everyDayHM(tb, value);
                break;
            case 6: {
                //cron表示式
                char[] chars = qrtzqTriggers.getTimeIntreval().toCharArray();
                String expression = "";
                int k = 0;
                for (int i = 0; i < chars.length; i++) {
                    if (k >= 5) {
                        expression += chars[i];
                    }
                    if (chars[i] == ',') {
                        k++;
                    }
                }
                try {
                    cronScheduler(tb, expression);
                } catch (Exception e) {
                    e.printStackTrace();
                    throw new BusinessException("cron表示式驗證錯誤。");
                }
            }
        }
    }

    /***
     * 執行一次*
     * @param tb
     * @param value
     */
    private void excuteOnce(TriggerBuilder<Trigger> tb, String[] value) {
        Date date = DateUtils.convertString(value[0]);
        tb.startAt(date);
        tb.withDescription("執行一次,執行時間:" + DateUtils.getFormatedDate(date, "yyyy-MM-dd HH:mm:ss"));
    }

    /***
     * 每天某分鐘執行*
     * @param tb
     * @param value
     */
    @SuppressWarnings("unchecked")
    private void everyDayMinute(TriggerBuilder<Trigger> tb, String[] value) {
        int minute = Integer.parseInt(value[1]);
        ScheduleBuilder sb = CalendarIntervalScheduleBuilder.calendarIntervalSchedule().withIntervalInMinutes(minute);

        tb.startNow();
        tb.withSchedule(sb);
        tb.withDescription("每:" + minute + "分鐘執行!");
    }

    /***
     * 每天某小時某分執行 *
     * @param tb
     * @param value
     */
    @SuppressWarnings({"unchecked"})
    private void everyWeekHM(TriggerBuilder<Trigger> tb, String[] value) throws BusinessException {
        StringBuffer aryBuString = new StringBuffer();
        @SuppressWarnings("unused")
        String week = getValues(value, aryBuString);
        //獲得周
        String getweek = getWeek(aryBuString);
        //獲得小時
        String gethour = getHour(aryBuString);
        String[] aryTime1 = gethour.split(":");
        String h1 = aryTime1[0];
        String m1 = aryTime1[1];
        String cronExperssion = "0 " + m1 + " " + h1 + " ? * " + getweek;
        ScheduleBuilder sb4 = null;
        try {
            sb4 = CronScheduleBuilder.cronSchedule(cronExperssion);
        } catch (Exception e) {
            log.error("CronScheduleBuilder.cronSchedule error", e);
            throw new BusinessException(e.getMessage());
        }
        tb.startNow();
        tb.withSchedule(sb4);
        StringBuffer weekName = new StringBuffer();
        for (int i = 0; i < getweek.split(",").length; i++) {
            weekName.append(DateUtils.getWeek(Integer.parseInt(getweek.split(",")[i])) + ",");
        }
        String getWeekName = weekName.substring(0, weekName.length() - 1).toString();
        tb.withDescription("每週:" + getWeekName + "," + h1 + ":" + m1 + "執行!");
    }

    /***
     * 獲得傳入引數*
     *
     * @param value
     * @param aryBuString
     * @return
     */
    private String getValues(String[] value, StringBuffer aryBuString) {
        String week = "";
        int aryLength = value.length;
        for (int i = 0; i < aryLength; i++) {
            week = value[i].toString();
            if (!week.isEmpty()) {
                aryBuString.append(value[i] + ",").toString();
            }
        }
        return week;
    }

    /***
     * 獲得周*
     *
     * @param aryBuString
     * @return
     */
    private String getWeek(StringBuffer aryBuString) {
        String getweek = aryBuString.toString();
        getweek = getweek.substring(0, getweek.length() - 1);
        int idx = getweek.lastIndexOf(",");
        getweek = getweek.substring(0, idx);
        return getweek;
    }

    /***
     * 獲得天*
     *
     * @param aryBuString
     * @return
     */
    private String getDays(StringBuffer aryBuString) {
        String getDays = aryBuString.toString();
        getDays = getDays.substring(0, getDays.length() - 1);
        int idx = getDays.lastIndexOf(",");
        getDays = getDays.substring(0, idx);
        return getDays;
    }

    /***
     * 獲得小時*
     *
     * @param aryBuString
     * @return
     */
    private String getHour(StringBuffer aryBuString) {
        String gethour = aryBuString.toString();
        gethour = gethour.substring(0, gethour.length() - 1);
        int idx1 = gethour.lastIndexOf(",");
        gethour = gethour.substring(idx1 + 1, gethour.length());
        return gethour;
    }

    /***
     * 每天某小時某分執行*
     *
     * @param tb
     * @param value
     */
    @SuppressWarnings("unchecked")
    private void everyDayHourMinue(TriggerBuilder<Trigger> tb, String[] value) {
        String[] aryTime = value[2].split(":");
        int hour = Integer.parseInt(aryTime[0]);
        int m = Integer.parseInt(aryTime[1]);
        ScheduleBuilder sb1 = CronScheduleBuilder.dailyAtHourAndMinute(hour, m);
        tb.startNow();
        tb.withSchedule(sb1);
        tb.withDescription("每天:" + hour + ":" + m + "執行!");
    }

    @SuppressWarnings({"unchecked"})
    private void everyDayHM(TriggerBuilder<Trigger> tb, String[] value) {
        StringBuffer aryBuString = new StringBuffer();
        @SuppressWarnings("unused")
        String week = getValues(value, aryBuString);
        //獲得天
        String getday = getDays(aryBuString);
        //獲得小時
        String gethour = getHour(aryBuString);
        String[] aryTime2 = gethour.split(":");
        String h2 = aryTime2[0];
        String m2 = aryTime2[1];
        String cronExperssion1 = "0 " + m2 + " " + h2 + " " + getday + " * ?";
        ScheduleBuilder sb5 = null;
        try {
            sb5 = CronScheduleBuilder.cronSchedule(cronExperssion1);
        } catch (Exception e) {
            log.error("CronScheduleBuilder.cronSchedule error", e);
        }
        tb.startNow();
        tb.withSchedule(sb5);
        String dayName = DateUtils.getDay(getday);
        tb.withDescription("每月:" + dayName + "," + h2 + ":" + m2 + "執行!");
    }


    /***
     * cron表示式*
     *
     * @param tb
     * @param expression
     */
    @SuppressWarnings({"unchecked"})
    private void cronScheduler(TriggerBuilder<Trigger> tb, String expression) {
        ScheduleBuilder sb6 = null;
        try {
            sb6 = CronScheduleBuilder.cronSchedule(expression);
        } catch (Exception e) {
            e.printStackTrace();
        }
        tb.startNow();
        tb.withSchedule(sb6);
        tb.withDescription("CronTrigger表示式:" + expression);
    }

}

(二)實際的jod

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
import org.springframework.stereotype.Component;

@Component
public class TestTimer extends QuartzScheduleBaseTimer {

    private static final Logger logger = LoggerFactory.getLogger(AccountExportTimer.class);

    @Override
    public JobExecution doJob(JobDataMap dataMap, JobExecutionContext context)
            throws Exception {
       //實現

    }
    public CommonService getCommonService(){
        return (CommonService)SpringContextHolder.getBean("commonService");
    }
    public Job getAccountExportJob(){
        return (Job)SpringContextHolder.getBean("exportJob");
    }
}

(三)spring batch


import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecutionListener;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
import org.springframework.batch.core.launch.support.RunIdIncrementer;
import org.springframework.batch.core.listener.JobExecutionListenerSupport;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.ItemWriter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.SimpleAsyncTaskExecutor;

/**
* @ClassName:AccountExportJob
* @author:
* @Description:
* @date:2017年7月24日 下午4:46:23
 */
@Configuration
@EnableBatchProcessing
@EnableAutoConfiguration
public class TestJob {
    @Autowired
    public JobBuilderFactory jobBuilderFactory;

    @Autowired
    public StepBuilderFactory stepBuilderFactory;

    @Autowired
    private JobStepListener listener;

    @Autowired
    private JobListener jobListener;

    /**
     * 讀資料
     *
     * @return
     */
    @SuppressWarnings("rawtypes")
    @Bean
    public ItemReader testReader() {
        return new testReader();
    }


    // 3.寫資料
    @SuppressWarnings("rawtypes")
    @Bean
    public ItemWriter testWriter() {
        return new testWriter();
    }

    @Bean
    public Job exportJob(JobBuilderFactory jobs, @Qualifier("testStep") Step testStep) {
        return jobs.get("testJob")
                .incrementer(new RunIdIncrementer())
                .listener(jobListener)
                .flow(accountExportStep)
                .end()
                .build();
    }
    @SuppressWarnings("unchecked")
    @Bean
    public Step testStep(StepBuilderFactory stepBuilderFactory) {
        return stepBuilderFactory.get("testStep")
                .listener(listener)
                .chunk(200)
                .reader(testReader())
                .writer(testWriter())
                .faultTolerant()
                .taskExecutor(new SimpleAsyncTaskExecutor())//設定併發方式執行
                .throttleLimit(10)//併發任務數為 10,預設為4
                .build();
    }
    @Bean
    public JobExecutionListener listener() {
        return new JobExecutionListenerSupport();
    }

}

*********************************reader***************************************8

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
@Component
public class TestReader extends MyBatisPagingItemReader<AccountEntry> implements
        StepExecutionListener {

    private static final Logger logger = LoggerFactory.getLogger(AccountExportReader.class);

    private StepExecution stepExecution;

    @Autowired
    private AccountEntryDataMapper accountEntryDataMapper;


    public AccountExportReader() {
        super();
        super.setQueryId("1000");
        setPageSize(10000);
    }

    @Autowired
    public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {
        super.setSqlSessionFactory(sqlSessionFactory);
    }
    @Override
    public ExitStatus afterStep(StepExecution stepExecution) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public void beforeStep(StepExecution stepExecution) {
        this.stepExecution = stepExecution;

    }
    @Override
    protected void doReadPage() {

    }
}

******************************************writer***********************************

import org.springframework.batch.core.ExitStatus;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.StepExecutionListener;
import org.springframework.batch.item.ItemWriter;
import org.springframework.beans.factory.annotation.Autowired;



/**
* @ClassName:AccountExportWriter
* @author:
* @Description:
* @date:2017年7月24日 下午3:45:49
 */
public class TestWriter implements ItemWriter, StepExecutionListener {

    private StepExecution stepExecution;
    @Autowired
    private AccountExportMapper accountExportMapper;

    @Override
    public ExitStatus afterStep(StepExecution stepExecution) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public void beforeStep(StepExecution stepExecution) {
        this.stepExecution = stepExecution;

    }
}


相關推薦

spring boot + spring batch+ quartz例項

注:本文非基礎教學類文章 首先工程用到的主要jar包 spring-batch-core-3.0.0.jar quartz-2.1.6.jar (一) quartz實現  實際開發過程中系統中肯定有任務管理模組,所以就按實際開發來寫了 import com.alibaba

精講Spring Boot—— 入門+進階+例項

Spring Boot到底是什麼 在瞭解Spring Boot之前應該先了解下Spring,因為Spring Boot的核心是基於Spring構建的。Spring是由Rod Johnson在2002年建立的一個開源框架,Spring在建立到現在一直處於飛速發展之中。目前已經成為J2EE開發中的事實標準。但是

Spring Boot整合Thymeleaf簡單例項

1、定義 Thymeleaf是一種用於Web和獨立環境的現代伺服器端的Java模板引擎。 2、簡單例項 (1)目錄結構 (2)MySpringBootApplication.java pa

Spring Boot整合持久化Quartz定時任務管理和介面展示

前言 本文是對之前的一篇文章Spring+SpringMVC+mybatis+Quartz整合程式碼部分做的一個修改和補充, 其中最大的變化就是後臺框架變成了Spring Boot。 本工程所用到的技術或工具有: Spring Boot Mybatis

spring boot 2.0 quartz 輕鬆實現定時任務和作業排程

    最近在做一個彩票相關的專案,主要涉及到不定時開獎,不定時封盤,原本打算使用spring boot 自帶的Schedule進行這一系列的工作,由於不能自動的新增定時任務,所以使用quartz,spring boot 2.0集成了quartz,所以決定嘗試下quartz用

Spring boot 下使用Kafka例項

一個簡單的例項 步驟: 1. 新增pom 2. 編寫配置檔案(生產者,消費者) 3. 測試 1. 新增pom### <dependency> <groupId>org.s

spring boot + spring batch 讀取資料庫檔案

----------------------------------------------------------------------------------------------------------------------------------一、配置JOBi

Spring Boot + Mybatis + 二級快取例項(Ehcache,Redis)

使用Mybatis自帶二級快取 MyBatis 包含一個非常強大的查詢快取特性,它可以非常方便地配置和定製。MyBatis 3 中的快取實現的很多改進都已經實現了,使得它更加強大而且易於配置。 預設情況下是沒有開啟快取的,除了區域性的 session 快取,可以增強

spring boot獲取注入的例項bean

之前實現的在spring boot裡整合的工具類獲取spring 注入的bean,期間出現很多問題,其中@configuartion一定要加。再是實現applicationContextAware介面! @Configuration   public class BeanT

Java - Struts框架教程 Hibernate框架教程 Spring框架入門教程(新版) sping mvc spring boot spring cloud Mybatis

java ee cloud pac .cn java get pin nat 輕量級 https://www.zhihu.com/question/21142149 http://how2j.cn/k/hibernate/hibernate-tutorial/31.html

spring boot + spring data jpa

分享 users pac frame 配置文件 .sql lda hash chan Spring Data Repository的核心接口是Repository(好像也沒什麽好驚訝的)。這個接口需要領域類(Domain Class)跟領域類的ID類型作為參數。這個接

Spring-Boot:Spring Cloud構建微服務架構

xmlns art 超時 客戶 微服務架構 cover lns created 搭建 概述:   從上一篇博客《Spring-boot:5分鐘整合Dubbo構建分布式服務》 過度到Spring Cloud,我們將開始學習如何使用Spring Cloud 來搭建微服務。繼續采

java電子商務系統源碼 Spring MVC+mybatis+spring boot+spring security

電子商務平臺 word 解決方案 功能 截圖 mybatis 互聯 包括 數據監控 鴻鵠雲商大型企業分布式互聯網電子商務平臺,推出PC+微信+APP+雲服務的雲商平臺系統,其中包括B2B、B2C、C2C、O2O、新零售、直播電商等子平臺。 分布式、微服務、雲架構電子商

Spring Boot + spring-data-redis

調用 ons cor spring edi start ota struct out Redis Redis是緩存, 消息隊列, 多種類型的key-value存儲服務. Spring Boot Spring Boot為Lettcue和Jedis客戶端提供自動註入配置

Maven工程搭建spring boot+spring mvc+JPA

sep validate 賬戶 onu target implement handler meta 驗證 添加Spring boot支持,引入相關包: 1、maven工程,少不了pom.xml,spring boot的引入可參考官網: <parent>

Angular集成Spring Boot,Spring Security,JWT和CORS

cli tput ces 編譯 pre ini pes 集成 dep 本文介紹了Spring Boot的基本配置,Angular集成Spring Boot、Spring Security的方法。當前流行的JWT更適合與Angular集成,優於Spring Secuity提供

redis jwt spring boot spring security 實現api token 驗證

BE output date art parent byte[] web rmi time 文章地址:http://www.haha174.top/article/details/258083 項目源碼:https://github.com/haha174/jwt-toke

小試 Spring Boot - Spring MVC

Spring前陣想試下 Spring MVC 4 有了些什麽新特性, 可真正用 Maven 在 IDE 中建立一個項目並不那麽容易. Spring 當初在笑 EJB 的笨重時如今把自己也搞大了, 繼而出臺了一個 Spring Boot 來響應微服務的號召.Spring Boot 的出世可以大大提升使用 Spr

Intellij+spring boot+spring MVC創建helloworld示例完整步驟

vcc turn 倉庫 pin oot type apach pro ali 1. 創建spring boot項目選擇spring initializr,然後選擇default點擊next,填寫項目信息點擊“next”,選擇web->web點擊“next”,填寫項目信

spring boot: spring-data-jpa (Repository/CrudRepository) 數據庫操作, @Entity實體類持久化

arp let private nic name service del ica Coding SpringBoot實現的JPA封裝了JPA的特性, Repository是封裝了jpa的特性(我是這麽理解的) 1在pom.xml引入mysql, spring-data-