SpringBoot 创建 console程序

2021-07-02 17:05

阅读:561

标签:import   接口   代码   使用   frame   end   ati   cat   plugins   

1.在pom中添加依赖

parent>
    groupId>org.springframework.bootgroupId>
    artifactId>spring-boot-starterartifactId>
    version>1.5.9.RELEASEversion>
parent>

dependencies>
    dependency>
        groupId>junitgroupId>
        artifactId>junitartifactId>
        version>4.11version>
        scope>testscope>
    dependency>
    dependency>
        groupId>org.springframework.bootgroupId>
        artifactId>spring-boot-starterartifactId>
    dependency>
dependencies>

build>
    plugins>
        plugin>
            groupId>org.apache.maven.pluginsgroupId>
            artifactId>maven-compiler-pluginartifactId>
            configuration>
                source>1.8source>
                target>1.8target>
            configuration>
        plugin>
        plugin>
            groupId>org.springframework.bootgroupId>
            artifactId>spring-boot-maven-pluginartifactId>
        plugin>
    plugins>
build>

2.修改Application.java 使用实现接口CommandLineRunner

修改Application.java 使用实现接口CommandLineRunner


package com.itstudy.springbootconsole;

import org.springframework.boot.Banner;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Application implements CommandLineRunner {

    public static void main(String[] args) {

        SpringApplication app = new SpringApplication(Application.class);
        app.setBannerMode(Banner.Mode.OFF);
        app.run(args);

    }

    public void run(String... arg0) throws Exception {
    //这里添加代码
    }

}

 

SpringBoot 创建 console程序

标签:import   接口   代码   使用   frame   end   ati   cat   plugins   

原文地址:https://www.cnblogs.com/liuxm2017/p/9629872.html


评论


亲,登录后才可以留言!