SpringBoot 创建 console程序
2024-09-05 21:28:27
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 {
//这里添加代码
} }
最新文章
- java注释指导手册
- 自动化测试selenium+java 第一章
- 【题解】【数组】【Leetcode】Merge Sorted Array
- 阿里云开放服务oss的api
- zigbee
- OC基础-day05
- POJ 1873 The Fortified Forest
- crontab问题处理
- 创建python虚拟环境如果速度很慢
- bootloaderd的再解析
- Inotify+Rsync实现Linux服务器文件同步
- Spark Streaming和Kafka整合保证数据零丢失
- 【原创】研发应该懂的binlog知识(下)
- iOS Message from debugger: Terminated due to memory issue ~解决方法
- 虚拟机克隆之后,网卡名称从eth0变成eth1之后的解决办法
- WEB 安全学习 一、mysql 注入漏洞
- Centos7升级新内核
- Intellij Idea搭建Spark开发环境
- 使用node新建一个socket服务器连接Telnet客户端并且进行输入的显示
- 执行automake时报错 error while making link: Operation not supported
热门文章
- ubuntu16.04 下安装jdk
- 【LuoguP3329&;4123】[ZJOI2011]最小割&;[CQOI2016]不同的最小割
- 微信小程序-坑1-await-async
- mysql 语句积累
- 2,ActiveMQ-入门
- Oulipo【Hash】
- 【bzoj3566】 [SHOI2014]概率充电器
- 【Java】使用@Valid+BindingResult进行controller参数校验
- php curl文件上传
- Redis 序列化方式StringRedisSerializer、FastJsonRedisSerializer和KryoRedisSerializer