idea创建多模块springboot项目
2023-09-11 14:15:07 时间
需求:一个父模块 下面几个子模块 其中一个模块是springboot结构。其他两个普通jar类型
有许多坑,都在注释里面写着呢。注意看父模块和demo模块的注释。
com.imooc.security 父模块
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
<?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> <!--父模块的基本信息--> <groupId>com.imooc.security</groupId> <artifactId>imooc-security</artifactId> <packaging>pom</packaging> <version>1.0-SNAPSHOT</version> <!--引入的子模块--> <modules> <module>imooc-security-core</module> <module>imooc-security-app</module> <module>imooc-security-browser</module> <module>imooc-security-demo</module> </modules> <!--版本控制参数,在父项目里面声明。--> <properties> <imooc.security.version>1.0-SNAPSHOT</imooc.security.version> </properties> <!--下面两个是版本管理,意识就是说引入这两个之后,他下面的子模块如果引入依赖就不用写版本号了 ,他俩给你们做了,自动引入版本号,避免因为引入的版本不兼容而引起的错误--> <dependencyManagement> <dependencies> <dependency> <groupId>io.spring.platform</groupId> <artifactId>platform-bom</artifactId> <version>Brussels-SR4</version> <type>pom</type> <scope>import</scope> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Dalston.SR2</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <!--父项目编译插件--> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.8</source> <target>1.8</target> <encoding>UTF-8</encoding> </configuration> </plugin> </plugins> </build> </project>
imooc-security-core 子模块
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
<?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"> <parent> <artifactId>imooc-security</artifactId> <groupId>com.imooc.security</groupId> <version>1.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>imooc-security-core</artifactId> <dependencies> <!--主要引入springseurity和oauth相关的jar,很重要的jar--> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-oauth2</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> <!--第三方登陆相关 begin--> <dependency> <groupId>org.springframework.social</groupId> <artifactId>spring-social-config</artifactId> </dependency> <dependency> <groupId>org.springframework.social</groupId> <artifactId>spring-social-core</artifactId> </dependency> <dependency> <groupId>org.springframework.social</groupId> <artifactId>spring-social-security</artifactId> </dependency> <dependency> <groupId>org.springframework.social</groupId> <artifactId>spring-social-web</artifactId> </dependency> <!--第三方登陆相关 end--> <dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> </dependency> <dependency> <groupId>commons-collections</groupId> <artifactId>commons-collections</artifactId> </dependency> <dependency> <groupId>commons-beanutils</groupId> <artifactId>commons-beanutils</artifactId> </dependency> <!--加速开发的工具,可以省略getset和日志类,只需要注解就可以--> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-configuration-processor</artifactId> </dependency> </dependencies> </project>
imooc-security-browser 子模块
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
<?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"> <parent> <artifactId>imooc-security</artifactId> <groupId>com.imooc.security</groupId> <version>1.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>imooc-security-browser</artifactId> <dependencies> <dependency> <groupId>com.imooc.security</groupId> <artifactId>imooc-security-core</artifactId> <version>${imooc.security.version}</version> </dependency> <dependency> <groupId>org.springframework.session</groupId> <artifactId>spring-session</artifactId> </dependency> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-core</artifactId> <version>1.2.2</version> </dependency> </dependencies> </project>
imooc-security-demo 子模块(这个模块是springboot结构,需要生成的jar可以跑在浏览器的)
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
<?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"> <parent> <artifactId>imooc-security</artifactId> <groupId>com.imooc.security</groupId> <version>1.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>imooc-security-demo</artifactId> <dependencies> <dependency> <groupId>com.imooc.security</groupId> <artifactId>imooc-security-browser</artifactId> <version>${imooc.security.version}</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-aop</artifactId> </dependency> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.7.0</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.7.0</version> </dependency> <dependency> <groupId>com.github.tomakehurst</groupId> <artifactId>wiremock</artifactId> </dependency> </dependencies> <!--这个是springboot的编译插件,如果不引入他的话,直接在父项目中执行打包命令,也会成功,但是所生成的 jar包里面没有依赖,只有几k大小,不知道为啥,所以我们要引入这个插件,帮助我们再次打包,原来的 也保留,只不过是xx.jar.original这种类型,xxxxx.jar是这个插件打包的jar。 然后执行java -jar filename.jar 就ok了 repackage的意思是重新打包的意思必须加 包名就是下面的 finalName --> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>2.0.1.RELEASE</version> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> </plugins> <finalName>demo</finalName> </build> </project>
相关文章
- 使用IDEA创建SpringBoot项目出现intellij idea No active profile set, falling back to default profiles: default
- SpringBoot添加HTTPS支持
- 微服务技术系列教程(08) - SpringBoot - 热部署(IDEA版)
- 微服务技术系列教程(05) - SpringBoot - 日志管理
- B站(云e办)SpringBoot实战练习的Sql文件、前端Vue源码、后端springboot源码
- 《SpringBoot篇》01.Springboot超详细入门(基础篇)
- SpringBoot 自定义Banner
- idea创建springBoot项目
- idea 使用idea上传项目到码云(gitee)上 IntelliJ IDEA
- SpringBoot自定义注解,Springboot权限角色注解
- IDEA创建SpringBoot,并实现、运行简单实例
- springboot之模板
- Windows下IDEA run能运行springboot,java -jar maven打的包拉有中文的nacos配置,报org.yaml.snakeyaml.error.YAMLException错误解决
- 基于springboot+vue的“体质测试数据分析及可视化设计”程序设计实现【毕业论文,源码】
- springboot入门 | 创建第一个springboot工程
- springboot汽车租赁系统源码来啦~
- IDEA SpringBoot项目工程中没有webService,选不到generate java code from wsdl
- IDEA从零到精通(16)之IDEA中用Spring Initializr创建springboot项目
- SpringBlade IDEA 配置SpringBoot多环境启动
- IDEA创建.gitignore文件模板忽略git提交.idea等文件
- SpringBoot设置全局上传文件路径并上传文件
- SpringBoot学习---第五篇:动态数据源(多数据源自动切换)
- SPRINGBOOT配置事物注解和@MAPPER注意
- eclipse打开多个Console窗口显示springboot项目启动情况
- SpringBoot简介&IDEA在线创建一个SpringBoot项目