在springboot项目中跑起来控制台项目:一个springboot的控制台项目: (1)、用spring-boot-starter替换掉spring-boot-starter-web,不然项目就会以web项目的方式启动. (2)、如果项目中有其他依赖了spring-boot-starter-web,必须exclude掉,例: <dependency> <groupId>com.xxxx.xxx</groupId> <artifactId>xxxx</artifactId> <exclusions> <exclusion> <groupId>org.spring work.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </exclusion> </exclusions> </dependency> (3)、在项目打包的时候,也要exculde掉web相关依赖。 <build> <plugins> <plugin> <groupId>org.spring work.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <excludeArtifactIds>tomcat*</excludeArtifactIds> <excludeArtifactIds>spring-web</excludeArtifactIds> <excludeGroupIds>io.springfox</excludeGroupIds> <excludes> <exclude> <groupId>org.spring work.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </exclude> <exclude> <groupId>org.spring work.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </exclude> </excludes> </configuration> </plugin> </plugins> </build> 然后将主入口文件写成: import org.spring work.boot.CommandLineRunner; import org.spring work.boot.SpringApplication; import org.spring work.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class CanalclientApplication implements CommandLineRunner { public static void main(String[] args) { System.out.println(" Hello Springboot!!!!!"); SpringApplication.run(CanalclientApplication.class, args); } @Override public void run(String... args) throws Exception { System.out.println(" This is console line!!!!!"); } } 就成了一个单独的命令行程序。 继续阅读与本文标签相同的文章
上一篇 :
如何创建Joomla快速安装包
下一篇 :
MySQL8.0.17 - 即将废弃的一些功能
-
《零起点Python大数据与量化交易》| 每日读本书
2026-05-20栏目: 教程
-
对象存储OSS的几个基本概念
2026-05-20栏目: 教程
-
https安全证书如何申请 https证书申请流程及费用
2026-05-20栏目: 教程
-
MySQL8.0.17 - 即将废弃的一些功能
2026-05-20栏目: 教程
-
SpringCloud----->在springboot项目中跑起来控制台项目
2026-05-20栏目: 教程
