Maven聚合项目的创建
2024-09-03 18:47:50
1.项目结构如下
步骤如下:
点击Finish
这里父项目需要加入如下的构建依赖:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-releasetrain</artifactId>
<version>Fowler-SR2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.0.2.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
再加入springboot的依赖:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
2.构建子项目
点击next修改名称完成构建 这里我们把a-first当做启动项目,需要在maven中加入:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
然后加入启动类:
@SpringBootApplication
@ComponentScan("com.test.*")
public class AfirstApplication {
public static void main(String[] args) {
SpringApplication.run(AfirstApplication.class);
}
}
b项目的建立
用同样的方式建立b项目 但不用建立启动类,我们项目a依赖b,如下:
在b中建立包com.test.bsecond,下面建立类TestRead:
public class TestRead {
public String eat(){
return "test eat";
}
}
在a中建立包com.test.afirst,下面建立包test,再建立类AReadB:
@Controller
public class AReadB {
@RequestMapping("/test")
@ResponseBody
public String test() {
TestRead testRead = new TestRead();
String eat = testRead.eat();
return eat;
}
}
现在执行mvn install,这个项目下面的所有的都打包完毕
然后我们运行启动类的jar包:
访问路径:http://localhost:8080/test 结果如下:
test eat
最新文章
- 看php手册2015-03-19版后备注
- Caused by: java.io.NotSerializableException: com.omhy.common.model.entity.XXX解决方法
- XML转换为对象操作类详解
- .NET 的webservice例子
- [D3] 7. Quantitative Scales
- Android/Linux boot time优化
- 每天学一点Docker(2)
- nginx的自动化安装和启停脚本
- linux:你不知道的echo
- spring security 学习笔记
- js:函数与变量作用域的提升
- Maven学习 一 概念介绍
- SQLServer最耗资源时间的SQL语句
- Unity3D 批处理场景的工具
- 009-docker-安装-redis:5.0.3
- Apache 强制Http跳转Https
- Html页面Dom对象之Element
- Please do not register multiple Pages in undefined.js 小程序报错的几种解决方案
- python30 excel修改模块xlutils
- Python接口测试实战5(下) - RESTful、Web Service及Mock Server
热门文章
- linux 查看网卡以及开启网卡
- Content-type解析
- RSA算法java实现(BigInteger类的各种应用)
- [Gamma阶段]第四次Scrum Meeting
- Net core学习系列(八)——Net Core日志
- UnityVR案例 - VR僵尸大战(HTC VIVE)
- linux , nginx: 封禁IP的办法【转】
- apache Request-URI Too Large 处理办法
- 为什么JDK代码这样写?final ReentrantLock takeLock = this.takeLock
- Jav面向对象