idea搭建springboot maven多模块项目

樱木花道VS康 发布于 2018/06/25 13:11
阅读 4K+
收藏 0

大家好我想搭建一个spring boot的多模块项目,比如:

demo-parent

    demo-dao

    demo-entity

    demo-service

    demo-web

每一个都是一个spring boot的项目,如果我想设置数据库连接:是不是在dao的模块下的yml配置?大家有没有好的案例分享下?谢谢了

加载中
0
木九天
木九天

springboot多模块项目的话,应该是这样子的,比如开源中国网站,他会有用户模块,博客模块,软件模块等等,这个需要用一个一个的项目分别搭建,但是你说的这个dao,service,web,entity不算是模块,貌似是培训出来的东西以及内容,你那个完全没有必要创建那么多项目,用一个项目就可以了,如果你想创建多个项目,像你刚刚提出来的那几个模块,一般情况下一个大项目需要短时间完成需要划分成几个小项目,然后分给几个团队去做,而你的dao,service即便分给几个团队,根本没法做,所以你的问题不对。

樱木花道VS康
樱木花道VS康
哦,有道理,网上查询有这么构建项目的,springmvc也有类似我描述的那样创建项目的。3q
0
LYB_124321
LYB_124321
你这是四层分层,不是四个项目分模块。 子项目是分别有自己的四层结构,什么都是自己独立的,建议看下服务的分解。
0
19shusheng点com
19shusheng点com
http://www.19shusheng.com/special/detail/aa9a45cbbb 看下这个是不是你想要的,怎么分模块。
0
netkiller-
netkiller-

父项目 

<?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>cn.netkiller</groupId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>pom</packaging>
	<name>moblearn</name>
	<description>Service project for Spring Boot</description>
	<url>http://maven.apache.org</url>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
		<java.version>1.8</java.version>
	</properties>

	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.0.2.RELEASE</version>
		<relativePath />
	</parent>

	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>org.springframework.cloud</groupId>
				<artifactId>spring-cloud-netflix</artifactId>
				<version>1.3.5.RELEASE</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
			<dependency>
				<groupId>org.springframework.cloud</groupId>
				<artifactId>spring-cloud-config</artifactId>
				<version>1.3.3.RELEASE</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
		</dependencies>
	</dependencyManagement>

	<dependencies>

	</dependencies>
	<modules>
		<module>api</module>
		<module>common</module>
		<module>feign</module>
		<module>example</module>
		<module>schedule</module>
		<module>zuul</module>
		<module>config</module>
		<module>eureka</module>
		<module>web</module>
		<module>backend</module>
		<module>wallet</module>
	</modules>

	<artifactId>parent</artifactId>
</project>

模块

<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>cn.netkiller.moblearn</groupId>
		<version>0.0.1-SNAPSHOT</version>
		<artifactId>parent</artifactId>
	</parent>
	<artifactId>api</artifactId>
	<name>api</name>
	<url>http://maven.apache.org</url>
	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
		<java.version>1.8</java.version>
	</properties>
	<dependencies>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-config</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-eureka</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-context</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-data-jpa</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-jdbc</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<scope>runtime</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</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-actuator</artifactId>
		</dependency>

		<dependency>
			<groupId>org.json</groupId>
			<artifactId>json</artifactId>
		</dependency>

		<dependency>
			<groupId>org.apache.logging.log4j</groupId>
			<artifactId>log4j-api</artifactId>
		</dependency>
		<dependency>
			<groupId>org.apache.logging.log4j</groupId>
			<artifactId>log4j-core</artifactId>
		</dependency>
		<dependency>
			<groupId>com.cwbase</groupId>
			<artifactId>logback-redis-appender</artifactId>
		</dependency>
		<dependency>
			<groupId>com.google.code.gson</groupId>
			<artifactId>gson</artifactId>
		</dependency>

		<dependency>
			<groupId>cn.netkiller.moblearn</groupId>
			<artifactId>common</artifactId>
		</dependency>

	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<release>10</release>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<configuration>
					<mainClass>api.Application</mainClass>
				</configuration>
			</plugin>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-plugin</artifactId>
				<configuration>
					<skip>true</skip>
				</configuration>
			</plugin>

		</plugins>
	</build>
	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>com.cwbase</groupId>
				<artifactId>logback-redis-appender</artifactId>
				<version>1.1.5</version>
			</dependency>
			<dependency>
				<groupId>cn.netkiller.moblearn</groupId>
				<artifactId>common</artifactId>
				<version>0.0.1-SNAPSHOT</version>
			</dependency>
		</dependencies>
	</dependencyManagement>
</project>

 

樱木花道VS康
樱木花道VS康
哇,费心了大神!3q
0
铂金大雕
铂金大雕

《maven实战》 第8章 聚合与继承 了解一下

返回顶部
顶部