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

最新文章

  1. 看php手册2015-03-19版后备注
  2. Caused by: java.io.NotSerializableException: com.omhy.common.model.entity.XXX解决方法
  3. XML转换为对象操作类详解
  4. .NET 的webservice例子
  5. [D3] 7. Quantitative Scales
  6. Android/Linux boot time优化
  7. 每天学一点Docker(2)
  8. nginx的自动化安装和启停脚本
  9. linux:你不知道的echo
  10. spring security 学习笔记
  11. js:函数与变量作用域的提升
  12. Maven学习 一 概念介绍
  13. SQLServer最耗资源时间的SQL语句
  14. Unity3D 批处理场景的工具
  15. 009-docker-安装-redis:5.0.3
  16. Apache 强制Http跳转Https
  17. Html页面Dom对象之Element
  18. Please do not register multiple Pages in undefined.js 小程序报错的几种解决方案
  19. python30 excel修改模块xlutils
  20. Python接口测试实战5(下) - RESTful、Web Service及Mock Server

热门文章

  1. linux 查看网卡以及开启网卡
  2. Content-type解析
  3. RSA算法java实现(BigInteger类的各种应用)
  4. [Gamma阶段]第四次Scrum Meeting
  5. Net core学习系列(八)——Net Core日志
  6. UnityVR案例 - VR僵尸大战(HTC VIVE)
  7. linux , nginx: 封禁IP的办法【转】
  8. apache Request-URI Too Large 处理办法
  9. 为什么JDK代码这样写?final ReentrantLock takeLock = this.takeLock
  10. Jav面向对象