gpt4 book ai didi

java - 使用mvn测试版本号时Maven无法解析依赖关系

转载 作者:行者123 更新时间:2023-11-30 05:31:03 25 4
gpt4 key购买 nike

你好,我有两个 Spring Boot 模块,一个中介类和一个模拟服务器类。 mediator 类有父 pom,mockserver 类有子 pom。它们在各自的端口上都有两个 Spring Boot 应用程序。

我正在尝试为中介类添加对模拟服务器类 pom 的依赖项,如下所示:

<dependency>
<groupId>com.nulogix</groupId>
<artifactId>billing_mediator</artifactId>
<version>${nulogix-release-number}-${git.version.number}</version>
<scope>compile</scope>
</dependency>

当我运行 mvn test 时,虽然我收到此错误,但我不知道为什么,因为版本是从父 POM 复制的。

[ERROR] Failed to execute goal on project mock_server: Could not resolve dependencies for project com.nulogix:mock_server:jar:0.9.6_M2-${git.commit.time}.${git.commit.id.describe-short}: Failure to find com.nulogix:billing_mediator:jar:0.9.6-M2 

这是我的中介 pom 文件:

    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.nulogix</groupId>
<artifactId>billing_mediator</artifactId>
<version>${nulogix-release-number}-${git.version.number}</version>
<packaging>pom</packaging>

<name>billing</name>
<url>http://maven.apache.org</url>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven-jaxb2-plugin.version>0.14.0</maven-jaxb2-plugin.version>
<jaxb2-specVersion>2.2</jaxb2-specVersion>
<git-commit-id-plugin.version>2.2.4</git-commit-id-plugin.version>
<nulogix-release-number>0.9.6_M2</nulogix-release-number>
<git.version.number>${git.commit.time}.${git.commit.id.describe-short}</git.version.number>
<nulogix-billing-response-schema>nulogixBillingResponse_1.1.xsd</nulogix-billing-response-schema>
</properties>

<dependencies>

<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformats-text</artifactId>
<version>2.10.0.pr1</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web-services</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>fluent-hc</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.2.11</version>
</dependency>
</dependencies>

<build>
<plugins>

<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>${maven-jaxb2-plugin.version}</version>
<executions>
<execution>
<id>id1-generate-service-end-point-from-wsdl</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<specVersion>${jaxb2-specVersion}</specVersion>
<schemaDirectory>${project.basedir}/src/main/resources/wsdl</schemaDirectory>
<schemaIncludes>
<include>*.wsdl</include>
</schemaIncludes>
<generateDirectory>${project.basedir}/target/generated-sources/xjc/billing_endpoint</generateDirectory>
<generatePackage>com.nulogix.billing.service</generatePackage>
</configuration>
</execution>
<execution>
<id>id2-generate-pojo-from-request-xsd</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<specVersion>${jaxb2-specVersion}</specVersion>
<schemaDirectory>${project.basedir}/src/main/resources/xsd/request</schemaDirectory>
<schemaIncludes>
<include>StudyDetailsSchema_3.17.6.12.xsd</include>
</schemaIncludes>
<bindingDirectory>${project.basedir}/src/main/resources/xsd/request</bindingDirectory>
<bindingIncludes>
<include>StudyDetailsSchema_3.17.6.12.xjb</include>
</bindingIncludes>
<generateDirectory>${project.basedir}/target/generated-sources/xjc/request_model</generateDirectory>
<generatePackage>com.nulogix.billing.model.request</generatePackage>
</configuration>
</execution>
<execution>
<id>id3-generate-pojo-from-response-xsd</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<specVersion>${jaxb2-specVersion}</specVersion>
<schemaDirectory>${project.basedir}/src/main/resources/xsd/response</schemaDirectory>
<schemaIncludes>
<include>${nulogix-billing-response-schema}</include>
</schemaIncludes>
<generateDirectory>${project.basedir}/target/generated-sources/xjc/response_model</generateDirectory>
<generatePackage>com.nulogix.billing.model.response</generatePackage>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <!-- surefire plugin version managed by Spring Boot -->
<configuration>
<skipTests>true</skipTests>
</configuration>
<executions>
<execution>
<id>unit-tests</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skipTests>false</skipTests>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
</execution>
<execution>
<id>integration-tests</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skipTests>false</skipTests>
<includes>
<include>**/*IT.*</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>



<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>revision</goal>
</goals>
</execution>
</executions>
<configuration>
<dateFormat>yyyyMMdd-HHmmss</dateFormat><!-- human-readable part of the version id -->
<dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
<generateGitPropertiesFile>true</generateGitPropertiesFile><!-- somehow necessary. otherwise the variables are not available in the pom -->
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Implementation-Version>${nulogix-release-number}-${git.version.number}</Implementation-Version>
<Git-Version-Number>${git.version.number}</Git-Version-Number>
</manifestEntries>
</archive>
</configuration>
</plugin>

</plugins>
<resources>
<resource>
<directory>resources</directory>
<targetPath>${project.build.outputDirectory}</targetPath>
<includes>
<include>application.properties</include>
</includes>
</resource>
</resources>
</build>
<modules>
<module>mock_server</module>
</modules>
</project>

这是我的模拟服务器 pom:

<?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>com.nulogix</groupId>
<artifactId>billing_mediator</artifactId>
<version>${nulogix-release-number}-${git.version.number}</version>
</parent>
<groupId>com.nulogix</groupId>
<artifactId>mock_server</artifactId>
<version>${nulogix-release-number}-${git.version.number}</version>
<name>mock_server</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven-jaxb2-plugin.version>0.14.0</maven-jaxb2-plugin.version>
<jaxb2-specVersion>2.2</jaxb2-specVersion>
<git-commit-id-plugin.version>2.2.4</git-commit-id-plugin.version>
<nulogix-release-number>0.9.6_M2</nulogix-release-number>
<git.version.number>${git.commit.time}.${git.commit.id.describe-short}</git.version.number>
<nulogix-billing-response-schema>nulogixBillingResponse_1.1.xsd</nulogix-billing-response-schema>
</properties>

<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformats-text</artifactId>
<version>2.10.0.pr1</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web-services</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>fluent-hc</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.2.11</version>
</dependency>
</dependencies>

<build>
<plugins>

<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>${maven-jaxb2-plugin.version}</version>
<executions>
<execution>
<id>id1-generate-service-end-point-from-wsdl</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<specVersion>${jaxb2-specVersion}</specVersion>
<schemaDirectory>${project.basedir}/src/main/resources/wsdl</schemaDirectory>
<schemaIncludes>
<include>*.wsdl</include>
</schemaIncludes>
<generateDirectory>${project.basedir}/target/generated-sources/xjc/billing_endpoint</generateDirectory>
<generatePackage>com.nulogix.billing.service</generatePackage>
</configuration>
</execution>
<execution>
<id>id2-generate-pojo-from-request-xsd</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<specVersion>${jaxb2-specVersion}</specVersion>
<schemaDirectory>${project.basedir}/src/main/resources/xsd/request</schemaDirectory>
<schemaIncludes>
<include>StudyDetailsSchema_3.17.6.12.xsd</include>
</schemaIncludes>
<bindingDirectory>${project.basedir}/src/main/resources/xsd/request</bindingDirectory>
<bindingIncludes>
<include>StudyDetailsSchema_3.17.6.12.xjb</include>
</bindingIncludes>
<generateDirectory>${project.basedir}/target/generated-sources/xjc/request_model</generateDirectory>
<generatePackage>com.nulogix.billing.model.request</generatePackage>
</configuration>
</execution>
<execution>
<id>id3-generate-pojo-from-response-xsd</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<specVersion>${jaxb2-specVersion}</specVersion>
<schemaDirectory>${project.basedir}/src/main/resources/xsd/response</schemaDirectory>
<schemaIncludes>
<include>${nulogix-billing-response-schema}</include>
</schemaIncludes>
<generateDirectory>${project.basedir}/target/generated-sources/xjc/response_model</generateDirectory>
<generatePackage>com.nulogix.billing.model.response</generatePackage>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <!-- surefire plugin version managed by Spring Boot -->
<configuration>
<skipTests>true</skipTests>
</configuration>
<executions>
<execution>
<id>unit-tests</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skipTests>false</skipTests>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
</execution>
<execution>
<id>integration-tests</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skipTests>false</skipTests>
<includes>
<include>**/*IT.*</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>



<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>revision</goal>
</goals>
</execution>
</executions>
<configuration>
<dateFormat>yyyyMMdd-HHmmss</dateFormat><!-- human-readable part of the version id -->
<dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
<generateGitPropertiesFile>true</generateGitPropertiesFile><!-- somehow necessary. otherwise the variables are not available in the pom -->
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Implementation-Version>${nulogix-release-number}-${git.version.number}</Implementation-Version>
<Git-Version-Number>${git.version.number}</Git-Version-Number>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>

我的模拟服务器应用程序将运行,但我的主应用程序不会(中介)

最佳答案

如果您想在项目的版本号中使用属性,则需要 ci 友好的属性 ( https://maven.apache.org/maven-ci-friendly.html )。其他属性只能在依赖项中使用,不能在您自己的版本号中使用。

关于java - 使用mvn测试版本号时Maven无法解析依赖关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57557275/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com