maven 相关问题

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

项目maven在服务器eclipsse上运行时出现错误“选择不包含任何可以在服务器上运行的资源”

我开始学习网络应用程序 我创建了一个 Maven 项目,但是当按在服务器 eclipsse 上运行时,它显示错误“选择不包含任何可以在服务器上运行的资源” 我使用 ecl...

回答 1 投票 0

Intellij Java 8 运行问题 - 无法识别的选项:--add-opens

我安装了最新的intellij,我想运行一个java 8项目,我正在使用最新版本的maven,构建安装工作正常,但是一旦我运行该项目,我得到无法识别的选项:--add...

回答 1 投票 0

使用本地父pom进行Maven多模块项目部署

我有一个关于本地父pom的使用的问题,当涉及到使用该父pom的工件的部署和发布时。 想象一下以下多模块 Maven 项目: - pom.x...

回答 1 投票 0

Heroku - 项目全栈(Java 和 Angular)的构建成功结束,但在应用程序站点(运行)上出现“应用程序崩溃”

我对全栈和 Spring Boot 还很陌生,所以请耐心等待。 我使用一本用于全栈开发的书,我首先尝试理解地阅读它,然后运行其中的程序。埃夫...

回答 1 投票 0

Maven 插件 jsonschema2pojo 返回 ClassNotFoundException

我需要从 JSON 模式生成 java pojo。我正在尝试使用 jsonschema2pojo maven 插件来实现此目的。我编写了自定义规则工厂,我想用它来生成 pojo。 这是我的

回答 2 投票 0

InjectMocks 错误地将相同的 Mock 注入到相似类型的 2 个不同字段中,尽管创建了 2 个不同的模拟

我有一个类,它有 2 个类似类型的字段。我曾经嘲笑过他们两个。但是当我使用 InjectMocks 时,注入模拟错误地将单个模拟注入到这两个字段中。 这是示例代码...

回答 2 投票 0

org.springframework.beans.factory.UnsatisfiedDependencyException:创建名称为“s3Controller”的bean时出错:表达了不满足的依赖关系

我正在使用 Maven 在 Java 17 上开发 AWS SDK v2 spring boot 项目,我尝试运行该文件,但它给了我一个错误,提示“org.springframework.beans.factory。”

回答 1 投票 0

如何在Maven中定义条件属性?

例如,如果有环境变量 AAA,我希望将属性 Configuration 设置为 ${env:AAA};如果没有这样的环境变量,则将属性 Configuration 设置为其他一些常量值。 怎么办...

回答 3 投票 0

Vaadin 24 构建成功,但从命令行执行失败,未找到 DevModeHandlerManager 实现,但启用了开发服务器

我正在尝试运行一个 vaadin 示例测试,我从 Vaadin 的站点启动项目开始,使用 Maven、Spring Boot 和 Apache Tomcat。 在 Eclipse 中运行它,它确实可以毫无问题地打开浏览器并且 ru...

回答 1 投票 0

Spring Boot应用程序无法在intellij idea中启动显示异常

我正在尝试在 Intellij Idea 中运行应用程序,但出现此错误...... org.springframework.beans.factory.BeanCreationException:错误 创建名称为“globalExceptionHandler”的 bean:Lo...

回答 2 投票 0

我无法编译minecraft插件

我正在开发一台 Minecraft 服务器,我需要为其测试一个插件。该插件在 github 上有源代码,我决定使用它们(我们正在讨论 MMOEconomy 插件)。 为了编译...

回答 1 投票 0

UnsupportedFeatureException:在图像堆中找到 ...NestedFileSystemProvider 类型的对象

我正在使用 graalvm-jdk-22.0.1+8.1 构建 spring-boot-starter 本机容器映像,但出现以下错误: [信息] [创建者] ================================================ =========...

回答 1 投票 0

Avro maven 插件无法重新定义类型

我在 quarkus 项目中使用 avro-maven-plugin: org.apache.avro avro-maven-插件 我在 quarkus 项目中使用 avro-maven-plugin: <plugin> <groupId>org.apache.avro</groupId> <artifactId>avro-maven-plugin</artifactId> <version>1.11.3</version> <configuration> ... </configuration> <executions> <execution> <phase>generate-sources</phase> <goals> <goal>schema</goal> </goals> <configuration> <includes> <include>**/*.avsc</include> </includes> <imports> <import>A.avsc</import> <import>B.avsc</import> </imports> </configuration> </execution> </executions> </plugin> 问题是关于插件中的导入部分。 文档说导入的文件不应互相引用,但在我的情况下,文件 A 和 B 都需要导入,并且 B 引用 A。 据我了解,这是不可能的并且失败: [错误] 无法在项目上执行目标 io.quarkus.platform:quarkus-maven-plugin:3.6.6:dev (default-cli) :无法执行 mojo:目标 org.apache.avro:avro- 的执行为 null maven-plugin:1.11.3:架构失败:无法重新定义:-> [帮助 1] 有什么解决办法吗? 看起来问题出在 quarkus maven 插件上。 当作为 quarkus:dev 的一部分运行此 Maven 任务时,构建失败, 但仅使用 Maven 运行它就可以了。 检查您是否使用 quarkus-maven-plugin 来实现 generate-code 目标。在这种情况下,使用 Maven 编译进行构建将起作用(正如您所描述的),因为只会使用您定义的插件和配置。将 quarkus:dev 与上述 generate-code 目标一起使用也将开始编译 Avro 文件,但没有导入配置,因为使用了另一个插件。 由于您使用的是 Quarkus,我建议使用他们的 Avro 模式生成方式。在这种情况下,您需要在 Quarkus 配置文件中的 avro.codegen.avsc.imports 下列出导入。更多信息在 有关调整 avro 代码生成的 Quarkus 文档 ;)

回答 2 投票 0

在Maven中配置hibernate-jpamodelgen

我想将 hibernate-jpamodelgen 配置到 Maven pom.xml 中。我试过这个: 我想将 hibernate-jpamodelgen 配置到 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>plugin</groupId> <artifactId>org.plugin</artifactId> <version>1.0</version> <packaging>jar</packaging> <name>Plugin</name> <url>http://maven.apache.org</url> <parent> ........ <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-jpamodelgen</artifactId> <version>5.4.3.Final</version> <scope>provided</scope> </dependency> </dependencies> <build> <finalName>datalis_plugin</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <source>10</source> <target>10</target> <encoding>${project.build.sourceEncoding}</encoding> <annotationProcessorPaths> <path> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.6</version> </path> </annotationProcessorPaths> <compilerArguments> <processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor> </compilerArguments> </configuration> </plugin> </plugins> </build> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> </project> 完整 POM:https://pastebin.com/VjucMAYL 但是我收到错误: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project org.plugin: Compilation failure [ERROR] Annotation processor 'org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor' not found 你知道我该如何解决这个问题吗? 我用过这个:https://docs.jboss.org/hibernate/jpamodelgen/1.0/reference/en-US/html_single/ 我通常只是将 hibernate-jpamodelgen 添加到编译器插件的注释处理器路径中。这会阻止处理器打包到部署中。 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <annotationProcessorPaths> <path> <groupId>org.mapstruct</groupId> <artifactId>mapstruct-processor</artifactId> <version>${org.mapstruct.version}</version> </path> <path> <groupId>org.hibernate</groupId> <artifactId>hibernate-jpamodelgen</artifactId> <version>5.4.3.Final</version> </path> </annotationProcessorPaths> </configuration> </plugin> 从 中删除 <scope>provided</scope> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-jpamodelgen</artifactId> <version>5.4.3.Final</version> </dependency> 添加插件 <plugins> ... <plugin> <groupId>org.bsc.maven</groupId> <artifactId>maven-processor-plugin</artifactId> <version>3.1.0</version> <executions> <execution> <id>process</id> <goals> <goal>process</goal> </goals> <phase>generate-sources</phase> <configuration> <processors> <processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor> </processors> </configuration> </execution> </executions> <dependencies> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-jpamodelgen</artifactId> <version>5.4.3.Final</version> </dependency> </dependencies> </plugin> ... </plugins> 然后重建 mvn clean package -DskipTests 这对我有用 pom.xml: <dependencies> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-jpamodelgen</artifactId> <scope>provided</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>11</source> <target>11</target> <annotationProcessorPaths> <path> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-configuration-processor</artifactId> <version>2.2.11.RELEASE</version> </path> <path> <groupId>org.hibernate</groupId> <artifactId>hibernate-jpamodelgen</artifactId> <version>5.4.22.Final</version> </path> </annotationProcessorPaths> </configuration> </plugin> </plugins> </build> <profiles> <profile> <id>dev</id> <activation> <activeByDefault>true</activeByDefault> </activation> <dependencies> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-jpamodelgen</artifactId> </dependency> </dependencies> <properties> <spring.profiles.active>dev</spring.profiles.active> </properties> </profile> </profiles> import com.mycompany.myapp.domain.*; // for static metamodels import com.mycompany.myapp.domain.User public class UserQueryService { private Specification<User> createSpecification(UserCriteria criteria) { Specification<User> specification = Specification.where(null); if (criteria != null) { if (criteria.getId() != null) { specification = specification.and(buildSpecification(criteria.getId(), User_.id)); } } return specification; } } 如果是 Java 12,请在 pom.xml 的构建中使用以下代码片段。 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.0</version> <configuration> <release>12</release> </configuration> </plugin> 在此之后,为 jpamodelgen 添加以下内容。 <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-jpamodelgen</artifactId> <version>5.4.3.Final</version> <optional>true</optional> </dependency> 将 hibernate-jpamodelgen 添加到我的依赖项并没有为我完成这项工作,而是创建了依赖项冲突,这导致 maven-enforcer-plugin 的 dependencyConvergence 抱怨,除非我将其与范围“受保护”结合起来。此外,在我看来,声明运行时依赖项似乎不太合理,除非我有一个。 事实证明这对我来说没有必要:我使用了 Cesar 的方法,但与 Cesar 的情况不同,我不需要添加 hibernate-jpamodelgen 或我的依赖项的其他任何内容。 我已经在maven-compiler-plugin中添加了一个处理器,即mapstruct-processor。 就像塞萨尔建议的那样,我将 hibernate-jpamodelgen 添加到该配置中。就我而言,结果是: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <source>11</source> <target>11</target> <annotationProcessorPaths> <path> <groupId>org.mapstruct</groupId> <artifactId>mapstruct-processor</artifactId> <version>1.4.2.Final</version> </path> <!-- The following path declaration is the only thing I added to make hibernate-jpamodelgen run --> <path> <groupId>org.hibernate</groupId> <artifactId>hibernate-jpamodelgen</artifactId> <version>5.3.20.Final</version> </path> </annotationProcessorPaths> </configuration> </plugin> 使用“maven-compiler-plugin”的正确解决方案。 如果您使用高于 3.1 的版本,请使用标签 compilerArgs。 如果您使用版本低于3.1,请使用标签compilerArguments 不要忘记删除不适合您的版本的相应标签。 为什么还使用“build-helper-maven-plugin”,请检查 Martin Baumgartner 在此线程中的答案。 通过将生成的源放入目标中,您将在 IDE 中遇到问题,因为找不到相关代码。因此,您可以添加 build-helper-maven-plugin 来动态添加目标目录中的文件夹 <build> <directory>${project.basedir}/target</directory> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>${maven.plugin.compiler.version}</version> <configuration> <annotationProcessorPaths> <path> <groupId>org.hibernate.orm</groupId> <artifactId>hibernate-jpamodelgen</artifactId> </path> </annotationProcessorPaths> <compilerArgs> <!-- Use this for plugin version HIGHER than 3.1, delete the other one --> <arg>-processor</arg> <arg>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</arg> </compilerArgs> <compilerArguments> <!-- Use this for plugin version LOWER than 3.1, delete the other one --> <processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor> </compilerArguments> </configuration> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>${build-helper-maven-plugin.version}</version> <executions> <execution> <id>add-source</id> <phase>process-classes</phase> <goals> <goal>add-source</goal> </goals> <configuration> <sources> <source>${project.basedir}/target/generated-sources/annotations</source> </sources> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build>

回答 6 投票 0

NoClassDefFoundError:无法初始化类 com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl

我正在尝试将项目从Java8迁移到Java9,但遇到了下面的运行时异常,我尝试了Stack-overflow社区和其他博客建议的所有可能的解决方案...

回答 5 投票 0

Allure/TestNG/Maven:org.testng.ITestNGListener:提供程序io.qameta.allure.testng.AllureTestNg无法实例化

我正在尝试将 Allure 集成到我的 Maven 项目中。这是我到目前为止所做的: - 安装命令行并设置类路径。作为验证的一部分,当我在控制台中运行 allure --version 时...

回答 4 投票 0

Maven 环境变量

我已将一个项目从 Eclipse 移植到 Maven,我需要设置一个环境变量以使我的项目正常工作。 在 Eclipse 中,我转到“运行”->“运行配置”,然后在选项卡环境下设置

回答 10 投票 0

Maven:如何重命名项目的war文件?

我有一个项目bird,在pom.xml中包含以下组件 com.myorg 鸟 1.0-快照...

回答 5 投票 0

Maven2中如何使用maven-simian-plugin?

我正在寻找 Simian 的 Maven2 报告插件,我发现的最接近此类报告的就是这个。问题是,它的文档似乎是针对 Maven 1 的。为什么是...

回答 1 投票 0

通过 Maven 生成 EJB 2 STUBS & TIES

最近我开始致力于将EJB项目迁移到Maven项目。我们在项目中使用EJB 2.0,我不知道如何开始迁移过程,目前现有的EJB项目包括...

回答 1 投票 0

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