maven 相关问题

Apache Maven是一个构建自动化和项目管理工具,主要用于Java项目。此标记用于与特定Maven版本无关的问题。使用gradle标签代替与Gradle相关的问题。

Maven 尝试为许可证-maven-插件使用错误的 groupId

我正在尝试将 mycila 版本的 maven-license-plugin 添加到遗留项目的根模块中: com.mycila 许可证-maven-p...

回答 1 投票 0

Quarkus 应用程序的 Prod 中缺少 Swagger UI

从 Quarkus 文档中,必须在 application.properties 中设置 quarkus.swagger-ui.always-include=true 才能在产品中构建 SwaggerUI。 默认情况下,Swagger UI 仅在 Quarkus

回答 1 投票 0


Spring Boot 无法将 MapStruct 注入容器,并出现错误:NoSuchBeanDefinitionException:没有类型的限定 bean

我尝试在 Spring Boot 项目中使用 MapStruct,但在将 MapStruct 定义的类注入容器时遇到问题。 错误描述: 描述: 构造参数1...

回答 1 投票 0

Maven 读取 .env 文件并设置环境变量

我有一个 .env 文件,其中包含以下内容: SOME_PROPERTY_I_NEED_IN_MY_UNIT_TESTS=xyz 我需要 Maven 加载此 .env 文件并将其中的所有变量导出为环境变量以进行测试。 这需要是一个文件...

回答 1 投票 0

Maven 配置文件属性在检索时始终给出 null

在我的 pom.xml 中,我定义了两个配置文件:澳大利亚和新西兰,因此根据所选配置文件,我可以检索我在属性中定义的值。 在我的 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"> <modelVersion>4.0.0</modelVersion> <groupId>org.country</groupId> <artifactId>CountryProfileMavenDemo</artifactId> <version>1.0-SNAPSHOT</version> <properties> <maven.compiler.source>14</maven.compiler.source> <maven.compiler.target>14</maven.compiler.target> </properties> <dependencies> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>7.4.0</version> <scope>test</scope> </dependency> </dependencies> <profiles> <profile> <activation> <activeByDefault>false</activeByDefault> </activation> <id>australia</id> <properties> <country.code>AU</country.code> <capital>Canberra</capital> <currency>AUD (Australian Dollar)</currency> </properties> </profile> <profile> <activation> <activeByDefault>false</activeByDefault> </activation> <id>newzealand</id> <properties> <country.code>NZ</country.code> <capital>Wellington</capital> <currency>NZD (New Zealand Dollar)</currency> </properties> </profile> </profiles> </project> 对于以下代码, package codes; import org.testng.annotations.Test; public class EnvironmentProfile { /* Based on the active Maven profile, Maven will set system properties (country.code, currency, and capital) accordingly. mvn clean install -P australia test To see which profile is active mvn help:active-profiles */ @Test public void testPrintEnvironmentDetails() { System.out.println("Country Code: " + System.getProperty("country.code")); System.out.println("Capital City: " + System.getProperty("capital")); System.out.println("Currency: " + System.getProperty("currency")); } } 从 IntelliJ Studio 我选择了配置文件并运行了代码,但我得到的输出为 国家代码:null 首都:null 货币:null 我尝试使用以下命令使用命令行,但没有成功。 mvn clean install -P australia test -DskipTests=false 按照@khmarbaise的建议,通过引用systemPropertyVariables中maven配置文件中定义的属性来解决。 在此 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"> <modelVersion>4.0.0</modelVersion> <groupId>org.country</groupId> <artifactId>CountryProfileMavenDemo</artifactId> <version>1.0-SNAPSHOT</version> <properties> <maven.compiler.source>14</maven.compiler.source> <maven.compiler.target>14</maven.compiler.target> <country.code>AU</country.code> <capital>Canberra</capital> <currency>AUD (Australian Dollar)</currency> </properties> <dependencies> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>7.4.0</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <systemPropertyVariables> <country.code>${country.code}</country.code> <capital>${capital}</capital> <currency>${currency}</currency> </systemPropertyVariables> </configuration> </plugin> </plugins> </build> <profiles> <profile> <id>australia</id> <!-- No need to define properties here --> </profile> <profile> <id>newzealand</id> <properties> <country.code>NZ</country.code> <capital>Wellington</capital> <currency>NZD (New Zealand Dollar)</currency> </properties> </profile> </profiles> </project> 如果在配置文件本身想要定义构建,请使用下面的 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"> <modelVersion>4.0.0</modelVersion> <groupId>org.country</groupId> <artifactId>CountryProfileMavenDemo</artifactId> <version>1.0-SNAPSHOT</version> <properties> <maven.compiler.source>14</maven.compiler.source> <maven.compiler.target>14</maven.compiler.target> </properties> <dependencies> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>7.4.0</version> <scope>test</scope> </dependency> </dependencies> <profiles> <profile> <id>australia</id> <properties> <country.code>AU</country.code> <capital>Canberra</capital> <currency>AUD (Australian Dollar)</currency> </properties> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <systemPropertyVariables> <country.code>${country.code}</country.code> <capital>${capital}</capital> <currency>${currency}</currency> </systemPropertyVariables> </configuration> </plugin> </plugins> </build> </profile> <profile> <id>newzealand</id> <properties> <country.code>NZ</country.code> <capital>Wellington</capital> <currency>NZD (New Zealand Dollar)</currency> </properties> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <systemPropertyVariables> <country.code>${country.code}</country.code> <capital>${capital}</capital> <currency>${currency}</currency> </systemPropertyVariables> </configuration> </plugin> </plugins> </build> </profile> </profiles> </project>

回答 1 投票 0

即使将 JAVA_HOME 设置为 jdk-17,Maven 也会继续恢复到 jdk-8

运行 mvn clean install 时,我不断遇到以下形式的错误: 无法在项目测试中执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (default-compile): Fatal ...

回答 1 投票 0

如何使用maven运行测试

当我在 java 项目中运行命令 mvn test 时,它显示 0 个测试正在运行。 src/test/java 下有一个名为 xyzTest.java 的测试文件,尽管我可以转到它并右键单击测试文件

回答 4 投票 0

Gradle 不寻找自定义 Maven 存储库

我有一个名为react-native-expofp的反应本机库,我正在尝试在那里添加CrowdConnected模块,根据此文档,我需要将实现“com.expofp:crowdconnected:4.2.12”添加到

回答 1 投票 0

Maven(surefire)测试插件排除不工作

我的 pom.xml 中有以下配置 maven-surefire-插件 2.17...

回答 5 投票 0

如何将pom.xml添加到现有的Eclipse项目中?

我是 Maven 新手,使用 Eclipse Juno。我已经安装了 Eclipse 的 Maven 集成。文件 > 新建 > 其他 > Maven 中有三个选项: 1. 从 SCM2 中签出 Maven 项目。 Maven 模块3.梅文

回答 2 投票 0

从intellij中的maven配置文件激活spring boot配置文件

我有一个多模块 Maven 项目,里面有一个 Spring Boot 项目。多模块项目有一个“dev”配置文件,Spring Boot 项目有一个 application-dev.properties 文件

回答 1 投票 0

我在尝试将图像上传到 S3 时在 Spring Framework 中遇到错误。请求签名不匹配

当我尝试将图像上传到 S3 时,出现以下错误。它说签名与提供的签名不匹配。 com.amazonaws.services.s3.model.AmazonS3Exception:请求

回答 1 投票 0

Maven 部署命令静默跳过部署

我有一个典型的java项目,我尝试使用mvn部署命令将其上传到nexus。 当我使用 mvn -X clean deploy -Dmaven.deploy.skip=false 运行它时,它在日志中显示: [调试] (f)

回答 1 投票 0

为什么javac目标选项不能低于源选项?

我已经阅读了 javac 的源和目标选项,它们分别定义了我的源代码编译所需的版本和我想要支持的最旧的 JRE 版本。在使用 Maven 时...

回答 2 投票 0

如何使用 Bazel 运行所有 JUnit 测试

我一直在尝试使用 Bazel 在目录中运行所有 JUnit 测试。据我所知,java_test规则只能运行特定的类。然而,我正在寻找更像 mv 的行为...

回答 2 投票 0

制作前端和后端(Angular 2 和 Spring)Maven 多模块项目

如何创建具有 Spring 后端和 Angular2 前端的 Maven 多模块项目?分别使用 spring initializr (https://start.spring.io) 和 Angular cli 似乎很简单,b...

回答 2 投票 0

Swagger-ui 不断显示示例 petstore 而不是我的 API

我对此有点迷失,因为它通常是开箱即用的。我正在制作一个小型 java spring-boot Rest api,为了获得漂亮的 API 描述和测试页面,我使用 Swagger。只是这次没有...

回答 3 投票 0

在新的 Maven 项目上:无法计算构建计划:插件 org.apache.maven.plugins:maven-resources-plugin:2.6?

我正在使用 Spring Tool Suite,带有嵌入的 Maven,在创建新的 Maven 项目时遇到这个问题。 我已经尝试过类似帖子中给出的每个答案;清理存储库并重建,代理在

回答 2 投票 0

在 Log4j 2.x Core 中保留 30 个归档日志文件

我想以这样的方式配置 log4j2.properties 文件,其中我的 swapi.log 条目删除所有以前写入的日志,例如,如果我们要删除最多 30 个条目的日志条目,一旦达到...

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.