提交 4f454c27 编写于 作者: Y yadong.zhang

ApplactionRunner

上级 446445f9
package com.zyd.blog;
import com.zyd.blog.business.enums.QiniuUploadType;
import com.zyd.blog.plugin.QiniuApi;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.io.File;
import java.io.IOException;
@RunWith(SpringRunner.class)
@SpringBootTest
public class BlogAdminApplicationTests {
@Test
public void contextLoads() {
File file = new File("C:\\x\\x.png");
try {
String filePath = QiniuApi.getInstance()
.withFileName(file.getName(), QiniuUploadType.SIMPLE)
.upload(file);
System.out.println(filePath);
} catch (IOException e) {
e.printStackTrace();
}
}
}
/**
* MIT License
* Copyright (c) 2018 yadong.zhang
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.zyd.blog.framework.runner;
import com.zyd.blog.business.consts.DateConst;
import com.zyd.blog.util.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
import java.util.Date;
/**
* 程序启动后通过ApplicationRunner处理一些事务
*
* @author yadong.zhang (yadong.zhang0415(a)gmail.com)
* @version 1.0
* @website https://www.zhyd.me
* @date 2018/6/6 16:07
* @since 1.0
*/
@Slf4j
@Component
public class BlogApplicationRunner implements ApplicationRunner {
@Override
public void run(ApplicationArguments applicationArguments) {
log.info("博客部署完成,当前时间:" + DateUtil.date2Str(new Date(), DateConst.YYYY_MM_DD_HH_MM_SS_EN));
}
}
......@@ -19,18 +19,11 @@
*/
package com.zyd.blog;
import com.zyd.blog.business.consts.DateConst;
import com.zyd.blog.util.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import java.util.Date;
/**
* 程序启动类
*
......@@ -40,18 +33,13 @@ import java.util.Date;
* @date 2018/4/18 11:48
* @since 1.0
*/
@Slf4j
@SpringBootApplication
@ServletComponentScan
@EnableTransactionManagement
public class BlogWebApplication implements ApplicationRunner {
public class BlogWebApplication {
public static void main(String[] args) {
SpringApplication.run(BlogWebApplication.class, args);
}
@Override
public void run(ApplicationArguments applicationArguments) {
log.info("博客部署完成,当前时间:" + DateUtil.date2Str(new Date(), DateConst.YYYY_MM_DD_HH_MM_SS_EN));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册