maven 工程构建 之_____<dependencyManagement>标签
<?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.zyt</groupId> <artifactId>fusunDemo</artifactId> <version>1.0-SNAPSHOT</version> <modules> <module>zyt_biz</module> <module>zyt_frame</module> </modules> <packaging>pom</packaging> <dependencyManagement> <dependencies> <dependency> <groupId>com.zyt</groupId> <artifactId>zyt_schema_core</artifactId> <version>${schema.version}</version> </dependency> </dependencies> </dependencyManagement> <profiles> <!--dat环境--> <profile> <id>DAT</id> <properties> <schema.version>1.0-SNAPSHOT</schema.version> <env>dat</env> </properties> </profile> </profiles> </project>
这个是顶级父工程的pom.xml文件
import com.jcraft.jsch.ChannelSftp; import org.apache.log4j.Logger; /** * @description: * @author: zhangyantao(张艳涛) * @createDate: 2020/11/23 * @version: 1.0 */ public class SftpUtil { private static Logger log= Logger.getLogger(SftpUtil.class); private ChannelSftp sftp; }
这个是子工程的一个类,这里的ChannelSftp 依赖的是顶级父工程的zyt_schema_core的依赖,但现在用不了依赖,
不会引入实际依赖,能约束dependecies下的依赖的依赖使用,继承了版本定义,子模块需要dependency引入<次依赖>不要带<version>版本
<?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>zyt_biz_frame</artifactId> <groupId>com.zyt</groupId> <version>1.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <groupId>com.zyt</groupId> <artifactId>zyt_biz_frame_utility</artifactId> <version>1.0-SNAPSHOT</version> <name>zyt_biz_frame_utility</name> <!-- FIXME change it to the project's website --> <url>http://www.example.com</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> <scope>test</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>log4j-over-slf4j</artifactId> <version>1.7.25</version> </dependency> <dependency> <groupId>com.zyt</groupId> <artifactId>zyt_schema_core</artifactId> </dependency> </dependencies> <build> ... </build> </project>