侧边栏壁纸
博主头像
小鱼吃猫博客博主等级

你所热爱的,便是你的生活。

  • 累计撰写 114 篇文章
  • 累计创建 47 个标签
  • 累计收到 9 条评论

目 录CONTENT

文章目录

在idea中创建多模块的SpringBoot项目

小鱼吃猫
2022-09-19 / 0 评论 / 0 点赞 / 206 阅读 / 2338 字

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.2.2.RELEASE:repackage (repackage) on project dao: Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:2.2.2.RELEASE:repackage failed: Unable to find main class -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

将父项目中的这段代码复制到web模块中,因为这上sprinboot项目打包的插件。
```xml
	<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>	

当然,为了避免出现不必要的错误,我更建议直接对modulepackage这个父项目进行install
依次对dao和service执行了install后,可以在本地maven仓库中找到它们:
ao和service执行

然后对web模块进行打包,打包完成后,会在它的target文件夹下生成jar文件,我们运行这上jar文件
后对web模块进行打包

java -jar web-0.0.1-SNAPSHOT.jar

然后这个项目就可以上线了。

8.2多人协作时

我们使用压缩包的方式打开上边这个打包好的jar包,可以在里边找到刚才的service和dao打包成的jar包
jar包
也就是说,在对we模块打包时,是将本地仓库中的maven仓库中的service和dao的jar包打包了进去,如果是多人协作的话,最好创建一个maven私服,这样就会更加方便

  • 总结:
  • 1.在实际工作中,肯定不止一个web,service,dao。请在命名时做到见名知义。
  • 2.除了web层,其他的子模块最终会被打包成jar包,放在web包中,只需要运行这一个jar包就可以了
  • 3.父工程的打包方式一定要是pom,即
    <packaging>pom</packaging>

项目源代码地址

0

评论区