亲宝软件园·资讯

展开

Maven 搭建spring boot多模块 详解Maven 搭建spring boot多模块项目(附源码)

tomato 人气:0
想了解详解Maven 搭建spring boot多模块项目(附源码)的相关内容吗,tomato在本文为您仔细讲解Maven 搭建spring boot多模块的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:springboot,maven模块,springboot多模块项目,spring,boot,多模块,下面大家一起来学习吧。

本文介绍了Maven 搭建spring boot多模块项目,分享给大家,具体如下:

备注:所有项目都在idea中创建

1.idea创建maven项目

2.创建子模块(module)

3.修改子模块pom.xml配置

<?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>parent</artifactId>
    <groupId>com.luyh.projectv1</groupId>
    <version>1.0-SNAPSHOT</version>
    <relativePath>../pom.xml</relativePath>
  </parent>
  <modelVersion>4.0.0</modelVersion>

  <artifactId>projectv1-model</artifactId>
</project>

注意:<font color="red"><relativePath>../pom.xml</relativePath></font>此段必须加上,用来继承父模块

至此,项目的基础结构搭建完毕了,接下来可以来撸代码了,哦哦稍等,我先介绍下各个子module的工作职责吧

4.子模块在项目中担任的'工作职责'

5.model层实体类编写

6.dao层数据库操作层

7. service 编写业务逻辑

8. webapi 编写webapi获取json数据

9.sql文件 请自行导入mysql数据 sql文件

这里是项目地址,点击下载

附录1

<?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.luyh.projectv1</groupId>
  <artifactId>parent</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>pom</packaging>
  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.3.3.RELEASE</version>
  </parent>
  <modules>

    <module>model</module>
    <module>dao</module>
    <module>service</module>
    <module>webapi</module>
  </modules>

  <!--申明依赖关系-->
  <dependencies>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-jdbc</artifactId>
    </dependency>

    <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis-spring</artifactId>
      <version>1.2.2</version>
    </dependency>
    <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis</artifactId>
      <version>3.2.8</version>
    </dependency>

    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-jdbc</artifactId>
    </dependency>

    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
    </dependency>
  </dependencies>

  <!--设置maven仓库-->

  <repositories>
    <repository>
      <id>spring-releases</id>
      <url>https://repo.spring.io/libs-release</url>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <id>spring-releases</id>
      <url>https://repo.spring.io/libs-release</url>
    </pluginRepository>
  </pluginRepositories>


</project>

加载全部内容

相关教程
猜你喜欢
用户评论