1. 因为社区办不支持使用spring Spring Initializr 的方式创建项目, 但是我们可以考虑使用别的方式达到效果:

创建方式有3种:

第一种:使用https://start.spring.io/ 官方URL创建项目,再导入到 IDEA Community Edition(后面简称:ideaC)。具体使用自行百度。缺点:没办法自定义springboot的版本。

第二种:下载插件:Spring boot Assistant, 然后就可以按照商业版的方式创建。

第三种:也是我今天推荐使用的方式。用ideaC的方式来创建:

1. 创建父工程:

2. 右键父项目,新建第一个子模块idea-service:

3. 同样的方式再创建一个子项目idea-stub:

4. 修改父工程的pom文件,添加springboot-parent 依赖 及其你想添加的依赖:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging> <modules>
<module>idea-service</module>
<module>idea-stub</module>
</modules> <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.2</version>
<relativePath/>
</parent> <groupId>org.example</groupId>
<artifactId>demo-IdeaC</artifactId>
<version>1.0-SNAPSHOT</version> <properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

5. 查看idea-stub的依赖有没问题,因为我设计stub项目是为了暴露服务的,暂时不需要添加其他jar包:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.example</groupId>
<artifactId>demo-IdeaC</artifactId>
<version>1.0-SNAPSHOT</version>
</parent> <artifactId>idea-stub</artifactId> <properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </project>

6. 查看idea-service的依赖,主要是spring-web的jar包,这是主服务端,需要负责项目启动,还要添加IdeaDemoApplication 启动类:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.example</groupId>
<artifactId>demo-IdeaC</artifactId>
<version>1.0-SNAPSHOT</version>
</parent> <artifactId>idea-service</artifactId> <properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> <dependencies>
<!-- spring-boot启动相关依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>3.2.2</version>
</dependency>
</dependencies> </project>
 6.1  还需要修改2个子项目的打包方式为jar,父工程确认为pom:
 
6.2: 添加IdeaDemoApplication 启动类,要修改ComponentScan()扫描的地方:

package org.example;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync; @EnableAsync
@Configuration
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
@ComponentScan({"org.example.*"})
public class IdeaDemoApplication { public static void main(String[] args) {
SpringApplication.run(IdeaDemoApplication.class, args);
} }

7.  如果不需要加载数据源的话,配置启动应用程序:

8. 结果:

9. 如果需要配置数据源的话,需要添加yml文件,@SpringBootApplication(exclude =)要取消排除数据源:

IDEA社区版(IDEA Community Edition)创建Springboot父子项目的更多相关文章

  1. Eclipse创建Maven父子项目

    Eclipse创建Maven父子项目 - 木头若愚 - CSDN博客https://blog.csdn.net/jay_1989/article/details/53906995 创建maven项目是 ...

  2. 创建Maven父子项目以及它们的优点

    此文引用:https://blog.csdn.net/zxl8876/article/details/104180133 创建maven父子项目 第一步创建父项目: 新建一个普通的maven项目 删除 ...

  3. 社区版Intelij IDEA快速创建一个spring boot项目(找不到sping Initializer选项)

    首先作为一个初学spring boot的小白,在学习过程中肯定会遇到各种问题... So,问题出现:在我想快速创建spring boot项目时,却在新建列表中找不到sping Initializer这 ...

  4. 第三篇 -- IDEA 创建Springboot Web项目并用Jmeter测试

    上一节使用Django写的一个接口程序,这一节讲用IDEA配合Springboot创建web项目.一个是python,一个是java. 参考链接:http://www.uxys.com/html/Ja ...

  5. 二创建maven父子项目

    关于maven中的parent聚合一直都有没好好总结,固有这篇. ------------------------------------------------------------------- ...

  6. 创建maven父子项目(九)

    一.父子-聚合项目 通过 maven 可以创建父子-聚合项目. 所谓的父子项目,即有一个父项目,有多个子项目.这些子项目,在业务逻辑上,都归纳在这个父项目下,并且一般来说,都会有重复的jar包共享.所 ...

  7. IDEA创建SpringBoot+maven项目

    1.创建项目: 2.选择spring Initializr,注意要选择jdk,使用默认的spring.io这样就不用再去写pom文件了 3.输入项目名称: 4.选择Spring Web 5.目录结构:

  8. intellij idea社区版 & maven & git & tomcat/jetty 的struts2项目的搭建

    1.新建一个project,并在project下新建一个maven module.

  9. idea创建springboot Web项目

    一.File —— New —— Project 二.next 三.选择你要的骨架,然后 next.个人觉的这些不用选,因为就是帮你建了几个文件夹,导入了几个jar包依赖而已. 四.Finish 五. ...

  10. Spring Boot2 系列教程(二)创建 Spring Boot 项目的三种方式

    我最早是 2016 年底开始写 Spring Boot 相关的博客,当时使用的版本还是 1.4.x ,文章发表在 CSDN 上,阅读量最大的一篇有 43W+,如下图: 2017 年由于种种原因,就没有 ...

随机推荐

  1. 学习笔记——Python基础

    字符串索引 str = '我是一名学生' print(str[0]) #输出"我" print(str[-6]) #输出"我" 字符串切片:把数据对象的一部分拿 ...

  2. Qt调用摄像头二,Pro版

    本示例,为纯Qt调用摄像头,功能会比版本一要多一点:打开摄像头,设置参数,完整拍照,框选拍照,切换分辨率,旋转,水平镜像,垂直镜像,放大,缩小 上一个版本,使用的显示窗口直接显示出摄像头画面,所以可操 ...

  3. spring boot @propertySource @importResource @Bean [六]

    @propertySource 指定property的配置源. 创建一个person.property: 然后修改person注解; 在运行test之后,结果为: @importResource 这个 ...

  4. c# 泛型原理(旧)

    前言 说起泛型可能很多人刚才看到的时候肯定会说牛逼啊,厉害啊,这东西少写了不少代码,我总结了泛型的一个优点,那就是少写代码,额,专业点吧. 优点:增加代码的重复利用率,代码重用. 先不讲原理吧,来讲下 ...

  5. 将项目封装进docker进行迁移和使用

    首先要理解docker的基本使用,本文不做过多阐述,博主也对docker没有了解透彻. 这里列一下docker的基本命令: docker info # 查看docker信息 docker -v # 查 ...

  6. 快速上手Linux核心命令

    Linux 的重要性不用我多说了吧,大多数互联网公司,服务器都是采用的Linux操作系统 Linux是一个主要通过命令行来进行管理的操作系统. 只有熟练掌握Linux核心命令,在使用起来我们才会得心应 ...

  7. CentOS7下安装Elasticsearch-7.3.2和Elasticsearch-head

    下载Elasticsearch-7.3.2-linux-x86_64.tar.gzElasticsearch下载地址:https://www.elastic.co/cn/downloads/elast ...

  8. 力扣647(java)-回文子串(中等)

    题目: 给你一个字符串 s ,请你统计并返回这个字符串中 回文子串 的数目. 回文字符串 是正着读和倒过来读一样的字符串. 子字符串 是字符串中的由连续字符组成的一个序列. 具有不同开始位置或结束位置 ...

  9. BizWorks助力企业应用的高效开发与复用

    简介: BizWorks作为企业级云原生应用数字工作台,能很好地支撑企业数字中台建设.云原生应用开发.企业资产运营管理等场景.本文不会全面介绍BizWorks平台的能力,而是着重介绍BizWorks在 ...

  10. 开源微服务编排框架:Netflix Conductor

    简介:本文主要介绍netflix conductor的基本概念和主要运行机制. ​ 作者 | 夜阳 来源 | 阿里技术公众号 本文主要介绍netflix conductor的基本概念和主要运行机制. ...