zoukankan      html  css  js  c++  java
  • SpringBoot 创建 console程序

    1.在pom中添加依赖

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.9.RELEASE</version>
    </parent>
    
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
    </dependencies>
    
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

    2.修改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 {
        //这里添加代码
        }
    
    }
  • 相关阅读:
    信息论
    学习抓包
    深入学习垃圾kafka
    share data
    【转载】计算图像相似度——《Python也可以》之一
    聊聊java list的使用特性
    log4j多线程以及分文件输出日志
    【转载】JDBC的连接参数的设置导致rowid自动添加到sql
    背包问题
    【转】【动态规划】01背包问题
  • 原文地址:https://www.cnblogs.com/liuxm2017/p/9629872.html
Copyright © 2011-2022 走看看