1)create new project ( 或 File --> new --> project)
2)选中Spring Initializr ,点击Next
![](http://upload-images.jianshu.io/upload_images/10861568-416aaa2515c6ea9f.png?imageMogr2/auto-orient/strip|imageView2/2/w/1200/format/webp)
image.png
3)填写必要信息,点击Next
![](http://upload-images.jianshu.io/upload_images/10861568-dc795182f726faad.png?imageMogr2/auto-orient/strip|imageView2/2/w/1200/format/webp)
image.png
4)依赖页不用勾选,点击Next
![](http://upload-images.jianshu.io/upload_images/10861568-815587431dd73135.png?imageMogr2/auto-orient/strip|imageView2/2/w/1200/format/webp)
image.png
5)选择项目存储目录,点击Finish
![](http://upload-images.jianshu.io/upload_images/10861568-839e91e7bde7bf31.png?imageMogr2/auto-orient/strip|imageView2/2/w/1200/format/webp)
image.png
6)在pom.xml中加入packaging
<packaging>pom</packaging>
7)删除多余文件
![](http://upload-images.jianshu.io/upload_images/10861568-365d7e3114241182.png?imageMogr2/auto-orient/strip|imageView2/2/w/698/format/webp)
image.png
8)清理、编译、打包
mvn clean install
9)在工程上右键,New-Module
![](http://upload-images.jianshu.io/upload_images/10861568-9be8681f4c6db1e2.png?imageMogr2/auto-orient/strip|imageView2/2/w/1200/format/webp)
image.png
![](http://upload-images.jianshu.io/upload_images/10861568-3986ffafe9fd33c5.png?imageMogr2/auto-orient/strip|imageView2/2/w/1200/format/webp)
image.png
10)填写子工程信息
![](http://upload-images.jianshu.io/upload_images/10861568-f74b56a497e3ef4e.png?imageMogr2/auto-orient/strip|imageView2/2/w/1200/format/webp)
image.png
11)选择依赖,点击Next
![](http://upload-images.jianshu.io/upload_images/10861568-e71b5879dd485597.png?imageMogr2/auto-orient/strip|imageView2/2/w/1200/format/webp)
image.png
12)点击Finish
![](http://upload-images.jianshu.io/upload_images/10861568-6804f58e065a7b54.png?imageMogr2/auto-orient/strip|imageView2/2/w/1200/format/webp)
image.png
13) 在父级pom.xml中增加modules
<modules>
<module>kafka-producer</module>
</modules>
14) 修改子级pom.xml中的parent节点
<parent>
<groupId>com.example.test</groupId>
<artifactId>kafka-test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
14) 删除子module中的多余文件
![](http://upload-images.jianshu.io/upload_images/10861568-89ef0f4379dede2e.png?imageMogr2/auto-orient/strip|imageView2/2/w/696/format/webp)
image.png
15)清理、编译、打包
mvn clean install
参考:
https://blog.csdn.net/longwind8/article/details/118657446
https://www.cnblogs.com/orzlin/p/9717399.html