maven-3 相关问题

Apache Maven是一个用于项目管理和构建自动化的工具。此标记用于与Maven版本3.x相关的问题。对于非特定版本的问题,请使用[maven]标记。

执行maven命令后出现“您指定的目标需要执行一个项目但该目录中没有POM”错误

我在 C:\Users\AArmijos\Desktop\Factura Electronica\MIy 中有一个 pom.xml

回答 0 投票 0

GitHub 作为 Maven 存储库 |创建 blob 时出错:未找到 (404)

以下是我使用 GitHub 作为 Maven 存储库已完成的步骤 创建了一个新的公共存储库:https://github.com/keshavram-roomie/library 去了 https://start.spring.io 和

回答 1 投票 0

如何强制 Maven 使用本地存储库而不是前往远程存储库来检索工件?

我在 Mac Yosemite 上使用 Maven 3.3.3 和 Java 8。我有一个多模块项目。 第一个模块 我的模块 我在 Mac Yosemite 上使用 Maven 3.3.3 和 Java 8。我有一个多模块项目。 <modules> <module>first-module</module> <module>my-module</module> … </modules> 当我使用“mvn clean install”构建我的一个子模块(例如上面的“my-module”)时,构建会尝试从我在 ~/.bashrc 中定义的远程存储库下载子模块工件。 m2/settings.xml 文件。输出如下 [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building my-module 87.0.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ Downloading: https://my.remoterepository.com/nexus/content/repositories/snapshots/org/mainco/subco/first-module/87.0.0-SNAPSHOT/maven-metadata.xml Downloading: http://download.java.net/maven/2/org/mainco/subco/first-module/87.0.0-SNAPSHOT/maven-metadata.xml Downloaded: https://my.remoterepository.com/nexus/content/repositories/snapshots/org/mainco/subco/first-module/87.0.0-SNAPSHOT/maven-metadata.xml (788 B at 0.9 KB/sec) Downloading: https://my.remoterepository.com/nexus/content/repositories/snapshots/org/mainco/subco/first-module/87.0.0-SNAPSHOT/first-module-87.0.0-20151104.200545-4.pom 如何强制 Maven 在尝试从远程存储库下载之前先检查我的本地 ~/.m2/repository?下面是我在 ~/.m2/settings.xml 文件中定义的远程存储库...... <profile> <id>releases</id> <activation> <property> <name>!releases.off</name> </property> </activation> <repositories> <repository> <id>releases</id> <url>https://my.remoterepository.com/nexus/content/repositories/releases/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> </profile> <profile> <id>snapshots</id> <activation> <property> <name>!snapshots.off</name> </property> </activation> <repositories> <repository> <id>snapshots</id> <url>https://my.remoterepository.com/nexus/content/repositories/snapshots/</url> <releases> <enabled>false</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> </profile> 编辑:响应说当工件不存在时会进行下载,下面是终端输出,其中我证明该文件在我的存储库中,但 Maven 无论如何都在尝试下载它...... Daves-MacBook-Pro-2:my-module davea$ ls -al ~/.m2/repository/org/mainco/subco/first-module/87.0.0-SNAPSHOT/first-module-87.0.0-SNAPSHOT.jar -rw-r--r-- 1 davea staff 10171 Nov 5 10:22 /Users/davea/.m2/repository/org/mainco/subco/first-module/87.0.0-SNAPSHOT/first-module-87.0.0-SNAPSHOT.jar Daves-MacBook-Pro-2:my-module davea$ mvn clean install [INFO] Scanning for projects... [WARNING] [WARNING] Some problems were encountered while building the effective model for org.mainco.subco:my-module:jar:87.0.0-SNAPSHOT [WARNING] 'build.plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration of plugin org.apache.maven.plugins:maven-antrun-plugin @ org.mainco.subco:my-module:[unknown-version], /Users/davea/Documents/sb_workspace/my-module/pom.xml, line 678, column 12 [WARNING] [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build. [WARNING] [WARNING] For this reason, future Maven versions might no longer support building such malformed projects. [WARNING] [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building my-module 87.0.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ Downloading: https://my.remoterepository.com/nexus/content/repositories/snapshots/org/mainco/subco/first-module/87.0.0-SNAPSHOT/maven-metadata.xml Downloading: http://download.java.net/maven/2/org/mainco/subco/first-module/87.0.0-SNAPSHOT/maven-metadata.xml Downloaded: https://my.remoterepository.com/nexus/content/repositories/snapshots/org/mainco/subco/first-module/87.0.0-SNAPSHOT/maven-metadata.xml (788 B at 0.8 KB/sec) Downloading: https://my.remoterepository.com/nexus/content/repositories/snapshots/org/mainco/subco/first-module/87.0.0-SNAPSHOT/first-module-87.0.0-20151106.043202-8.pom Downloaded: https://my.remoterepository.com/nexus/content/repositories/snapshots/org/mainco/subco/first-module/87.0.0-SNAPSHOT/first- module-87.0.0-20151106.043202-8.pom (3 KB at 21.9 KB/sec) Downloading: http://download.java.net/maven/2/org/mainco/subco/subco/87.0.0-SNAPSHOT/maven-metadata.xml Downloading: https://my.remoterepository.com/nexus/content/repositories/snapshots/org/mainco/subco/subco/87.0.0-SNAPSHOT/maven-metadata.xml 依赖项有快照版本。对于快照,Maven 将检查本地存储库,如果本地存储库中找到的工件太旧,它将尝试在远程存储库中查找更新的工件。这可能就是您所看到的。 请注意,此行为由存储库配置中的 updatePolicy 指令控制(快照存储库默认为 daily)。 使用mvn --help,您可以看到选项列表。 有一个类似-nsu,--no-snapshot-updates Suppress SNAPSHOT updates的选项 因此使用命令mvn install -nsu可以强制使用本地存储库进行编译。 要真正强制maven仅使用本地存储库,您可以使用mvn <goals> -o运行。 -o 告诉 maven 让你“离线”工作,并且它将远离网络。 请按照以下步骤操作: 确保删除本地 jar 文件夹中的所有内容,除了要保留的 jar 之外。 例如 .repositories、.pom、.sha1、.lastUpdated 等文件。 执行mvn clean install -o命令 这将有助于使用本地存储库 jar 文件,而不是连接到任何存储库。 就我而言,我有一个像你一样的多模块项目。我必须更改我的项目所依赖的外部库之一的组 ID,如下所示。 来自: <dependencyManagement> <dependency> <groupId>org.thirdparty</groupId> <artifactId>calculation-api</artifactId> <version>2.0</version> <type>jar</type> <scope>provided</scope> </dependency> <dependencyManagement> 致: <dependencyManagement> <dependency> <groupId>org.thirdparty.module</groupId> <artifactId>calculation-api</artifactId> <version>2.0</version> <type>jar</type> <scope>provided</scope> </dependency> <dependencyManagement> 注意部分。事实证明,我忘记修改在其 pom 文件中定义此依赖项的子模块的相应部分。 这让我非常抓狂,因为该模块在本地可用。 Maven 总是首先检查您的本地存储库,但是,您的依赖项需要安装在您的存储库中,以便 Maven 找到它。 首先在依赖模块中运行 mvn install,然后构建依赖模块。 即使考虑了上述所有答案,您仍然可能会遇到问题,从而导致您的 Maven 离线构建出错。特别是,您可能会遇到以下警告: [WARNING] The POM for org.apache.maven.plugins:maven-resources-plugin:jar:2.6 is missing, no dependency information available 警告之后将立即出现进一步的错误,maven 将终止。 对于我们来说,使用按照上述提示创建的 Maven 离线缓存进行离线构建的最安全方法是使用以下 Maven 离线参数: mvn -o -llr -Dmaven.repo.local=<path_to_your_offline_cache> ... 特别是,选项 -llr 可以防止您必须按照答案 #4 中的建议调整本地缓存。 另请注意,settings.xml 中的参数 指向本地 Maven 存储库的正确文件夹。 -o 选项对我不起作用,因为根据我得到的错误,该工件仍在开发中,尚未上传,maven(3.5.x)仍然尝试从远程存储库下载它,因为这是第一次. 但是这为我解决了这个问题:https://maven.apache.org/general.html#importing-jars 手动安装后,也无需使用离线选项。 更新 我刚刚重建了依赖关系,我必须重新导入它:常规的 mvn clean install 对我来说还不够 我也遇到了完全相同的问题。运行 mvn clean install 而不是 mvn clean compile 解决了这个问题。 仅在使用 multi-maven-project 时才会出现差异,因为项目依赖项是通过使用 install 上传到本地存储库的。 我也遇到了同样的问题。对我来说,这是 pom.xml 中缺少的 SNAPSHOT 文本。看起来,如果我们想强制maven从本地构建,我们需要提供-SNAPSHOT: <dependency> <groupId>com.ABC</groupId> <artifactId>QRS</artifactId> <version>1.2.65-SNAPSHOT</version> </dependency> 使用 只是给我 2 美分。对我来说,只需要在 ~/.m2/repository 目录中找到 jar 并使用它的版本。所以,使用后 cd local-dependency/ mvn install local-dependency罐子将位于.m2/repository/com/your-organization/local-dependency/中 ~$ tree ~/.m2/repository/com/your-organization/local-dependency/ /home/felipe/.m2/repository/com/your-organization/local-dependency/ ├── 0.1-SNAPSHOT │   ├── maven-metadata-local.xml │   ├── _remote.repositories │   ├── local-dependency-0.1-SNAPSHOT.jar │   ├── local-dependency-0.1-SNAPSHOT.pom │   └── resolver-status.properties └── maven-metadata-local.xml 然后将其用作本地依赖项 <dependency> <groupId>com.your-organization</groupId> <artifactId>local-dependency</artifactId> <version>0.1-SNAPSHOT</version> </dependency>

回答 11 投票 0

为什么maven在构建这个child_project时要搜索parent_project:pom:${revision}?

背景 目录布局 | |`parent_project/pom.xml | |`child_project/pom.xml 父pom 背景 目录布局 | |`parent_project/pom.xml | |`child_project/pom.xml 父pom <?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.example</groupId> <artifactId>parent_project</artifactId> <version>${revision}</version> <packaging>pom</packaging> <properties> <maven.compiler.source>8</maven.compiler.source> <maven.compiler.target>8</maven.compiler.target> </properties> </project> 儿童绒球 <?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> <parent> <artifactId>parent_project</artifactId> <groupId>org.example</groupId> <version>1.0-SNAPSHOT</version> </parent> <artifactId>child_project</artifactId> <version>${revision}</version> <properties> <maven.compiler.source>8</maven.compiler.source> <maven.compiler.target>8</maven.compiler.target> </properties> </project> 产生问题的步骤 构建父级 mvn clean install -Drevision=1.0-SNAPSHOT -U -f pom.xml 打造孩子 mvn clean install -Drevision=1.0-SNAPSHOT -U -f pom.xml 出现错误 Could not find artifact org.example:parent_project:pom:${revision} in remote-repo (url) 问题 我在子进程的父块中将父版本指定为 1.0-SNAPSHOT,那么为什么 maven 会尝试查找 org.example:parent_project:pom:${revision}? 当maven在构建child_project时开始查找parent_project:pom:${revision}时,${revision}目录被添加到.m2/repository/.../parent_project/ 答案重新设计,请查看末尾的链接以获取文档 multi module project 和 ci friendly links 以及 revision 参数。 示例(构建父级也构建子级,构建子级仅构建该子级): 目录布局 ...\parent\pom.xml ...\括号

回答 1 投票 0

Maven:警告无法使用环境中的“javac”自动检测“javac”路径

运行 Maven 时,我得到以下输出: [警告] 无法使用环境中的“javac”自动检测“javac”路径。 我该如何解决这个问题?

回答 13 投票 0

在Maven中设置环境变量

我有一个带有以下 application.properties 设置的 Spring Boot 应用程序。 #... spring.datasource.url=${JDBC_DATABASE_URL} 当我使用像 IntelliJ 这样的 IDE 时,我可以设置环境变量,它

回答 4 投票 0

如何解决 Maven 中的“无法收集依赖项”错误?

我在我的项目中使用Maven 3。它已经被搁置了一段时间,但我们最近又开始研究它。 当我尝试构建它时,出现以下错误: [错误] 失败...

回答 2 投票 0

如何在mavenized多模块项目中从CheckStyle分析中排除包?

我有一个包含多个模块的 Maven 项目,包括 org.eclipse.cdt.core。由于某种原因,客户也希望构建 org.eclipse.cdt.core。 我想生成一个聚合的 Checkstyle ...

回答 1 投票 0

maven如何对版本号进行排序?

Maven 似乎能够指示一系列版本,例如 [1.2.3,) 当没有一致的版本时,maven 如何确定什么是新版本或旧版本

回答 3 投票 0

Tomcat 9 的 Maven 插件

除了tomcat7-maven-plugin之外,我没有找到任何tomcat-maven-plugin。 我可以与 apache-tomcat-9.0.0.M15 一起使用吗?

回答 4 投票 0

未知的生命周期阶段“高”。您必须指定有效的生命周期阶段

当我使用“mvn clean install”目标运行我的sprint启动项目时,我收到了以下日志,请帮助解决这个问题。 [信息]最终内存:25M/87M 18:26:48 [信息] ----------------------...

回答 0 投票 0

Maven 发布插件问题 - 无法执行目标 org.apache.maven.plugins:maven-release-plugin:2.3.2:prepare

挣扎于maven:发布这个项目。看起来像是版本不兼容的问题,但我不知道如何纠正这个问题。我使用的是 Maven 版本 3.1.1。 这是我的 pom.xml (示例) <...

回答 2 投票 0

Maven 防止提供范围依赖的传递依赖

我有一个提供范围的 Maven 依赖项。它带来的传递依赖项没有标记为提供,而是标记为编译。 所以当我使用maven ass打包并创建jar文件时...

回答 0 投票 0

构建时出现 MojoExecutionException - Maven

以下是我在 pom 中构建 Maven 项目时包含的目标。 以下是我在 pom 中构建 Maven 项目时包含的目标。 <?xml version="1.0"?> <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/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.mynewproject.portlet</groupId> <artifactId>abc-myfacts-portlet</artifactId> <packaging>war</packaging> <name>ABC MY FACTS Portlet</name> <version>2.0-SNAPSHOT</version> <build> <plugins> <plugin> <groupId>com.liferay.maven.plugins</groupId> <artifactId>liferay-maven-plugin</artifactId> <version>${liferay.maven.plugin.version}</version> <executions> <execution> <phase>generate-sources</phase> <goals> <goal>build-css</goal> </goals> </execution> </executions> <configuration> <autoDeployDir>${liferay.auto.deploy.dir}</autoDeployDir> <appServerDeployDir>${liferay.app.server.deploy.dir}</appServerDeployDir> <appServerLibGlobalDir>${liferay.app.server.lib.global.dir}</appServerLibGlobalDir> <appServerPortalDir>${liferay.app.server.portal.dir}</appServerPortalDir> <liferayVersion>${liferay.version}</liferayVersion> <pluginType>portlet</pluginType> </configuration> </plugin> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>2.5</version> <configuration> <encoding>UTF-8</encoding> <source>1.6</source> <target>1.6</target> </configuration> </plugin> <plugin> <artifactId>maven-resources-plugin</artifactId> <version>2.5</version> <configuration> <encoding>UTF-8</encoding> </configuration> </plugin> </plugins> </build> <dependencies> <!-- Liferay dependency --> <dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> <version>2.6</version> </dependency> <dependency> <groupId>commons-collections</groupId> <artifactId>commons-collections</artifactId> <version>3.2.1</version> <optional>true</optional> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjrt</artifactId> <version>1.6.5</version> </dependency> <!-- <dependency> <groupId>org.springframework</groupId> <artifactId>spring-instrument</artifactId> <version>3.1.0.RELEASE</version> </dependency> --> <dependency> <groupId>com.liferay.portal</groupId> <artifactId>portal-service</artifactId> <version>${liferay.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.liferay.portal</groupId> <artifactId>util-bridges</artifactId> <version>${liferay.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.liferay.portal</groupId> <artifactId>util-taglib</artifactId> <version>${liferay.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.liferay.portal</groupId> <artifactId>util-java</artifactId> <version>${liferay.version}</version> <scope>provided</scope> </dependency> <!-- Portlet/JSR dependency --> <dependency> <groupId>javax.portlet</groupId> <artifactId>portlet-api</artifactId> <version>2.0</version> <scope>provided</scope> </dependency> <!-- Servlet/JSP dependency --> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.4</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <version>2.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> <scope>runtime</scope> </dependency> <!-- Spring dependency --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc-portlet</artifactId> <version>3.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>3.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>3.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>3.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>3.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>3.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> <version>3.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aspects</artifactId> <version>3.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-agent</artifactId> <version>2.5.6</version> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>1.6.12</version> </dependency> <dependency> <groupId>cglib</groupId> <artifactId>cglib-nodep</artifactId> <version>2.2.2</version> </dependency> <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>1.3</version> </dependency> <!-- Log4j configuration --> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.16</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.4.2</version> </dependency> <!-- Unit testing --> <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-all</artifactId> <version>1.9.5</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> </dependency> <!-- Data Service dependency --> <dependency> <groupId>com.mynewproject.components</groupId> <artifactId>abc-mynewproject-service</artifactId> <version>2.0-SNAPSHOT</version> </dependency> <dependency> <groupId>com.mynewproject.components</groupId> <artifactId>emailcomponent</artifactId> <version>2.0-SNAPSHOT</version> </dependency> </dependencies> <profiles> <profile> <id>Liferay-v6.2-EE-(Tomcat-7)</id> <properties> <liferay.version>6.2.2</liferay.version> <liferay.maven.plugin.version>7.0.0-m2</liferay.maven.plugin.version> <liferay.auto.deploy.dir>..\Liferay Portal\liferay-portal-6.2.10.1-ee-ga1\deploy</liferay.auto.deploy.dir> <liferay.app.server.deploy.dir>..\Liferay Portal\liferay-portal-6.2.10.1-ee-ga1\tomcat-7.0.42\webapps</liferay.app.server.deploy.dir> <liferay.app.server.lib.global.dir>..\Liferay Portal\liferay-portal-6.2.10.1-ee-ga1\tomcat-7.0.42\lib\ext</liferay.app.server.lib.global.dir> <liferay.app.server.portal.dir>..\Liferay Portal\liferay-portal-6.2.10.1-ee-ga1\tomcat-7.0.42\webapps\ROOT</liferay.app.server.portal.dir> </properties> </profile> </profiles> </project> 但是当我执行构建时,出现以下错误: [ERROR] 执行目标失败 com.liferay.maven.plugins:liferay-maven-plugin:6.2.1:build-css (默认)在项目 myNewProject 上:null:MojoExecutionException: NullPointerException -> [帮助 1] org.apache.maven.lifecycle.LifecycleExecutionException: 失败 执行目标 com.liferay.maven.plugins:liferay-maven-plugin:6.2.1:build-css (默认)在项目 myNewProject 上:null 在 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216) 在 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) 在 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) 在 org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:108) 在 org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76) 在 org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) 在 org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116) 在 org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361) 我的问题是: 当我执行构建时,是什么导致了空指针异常? 这个问题发生在我的 Mac 上。 我用 JAVA_HOME=/usr/libexec/java_home -v 1.8 切换到 JDK 8 echo $JAVA_HOME表演 /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home 原来这个JDK版本有问题 我使用JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_341.jdk/Contents/Home修复了它(在安装官方JDK8之后) 现在echo $JAVA_HOME演出 /Library/Java/JavaVirtualMachines/jdk1.8.0_341.jdk/Contents/Home 首先,您需要检查您正在使用的 liferay 版本,如果它在您的pom.xml中提到。 此外,当您尝试使用旧版本的 Maven 构建 Liferay 项目时,可能会抛出错误。使用命令检查您使用的 Maven 版本 mvn-版本 此外,您正在使用的 JDK 应该在您的 POM.xml 中正确提及。 我发现 khmarbaise 的评论是正确的,因为版本也可能存在冲突。希望这会有所帮助。

回答 2 投票 0

如何指定从父 maven 项目构建哪个子模块?

我有三个级别的 Maven 多模块项目。 祖父 -> 包括父亲 父亲 -> 包括多个儿子 儿子1 儿子2 儿子3 我的 Jenkins 工作触发了 Grand Father 项目的构建。即...

回答 0 投票 0

Spring boot:从 pom-xml 中删除了 spring security 依赖,但仍然在 Intellij 中生成密码

最初,我在应用程序中添加了 spring security 依赖项,但后来删除了它,但它仍然会生成密码。 Maven 全新安装无效。我也删除了 .idea 和 project....

回答 1 投票 0

##[错误]在池代理中找不到满足指定要求的代理:maven,代理.版本-gtVersion 2.163.1

我正在尝试在 Azure DevOps 服务上构建和发布管道,因为我在 Azure 中托管的 linuxVM 上使用自托管 Linux 代理 runnig。 早些时候,同样的管道在

回答 2 投票 0

Maven:依赖文件夹的权限被拒绝异常?

下面是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> <parent> <groupId>com.test</groupId> <artifactId>tel-test-parent</artifactId> <version>1.0</version> </parent> <properties> <artifactoryPackageName>wso2-esb-dist</artifactoryPackageName> <artifactoryPackageVersion>5.0.0</artifactoryPackageVersion> <artifactoryPackageClassifier>bin</artifactoryPackageClassifier> <artifactoryPackageExtension>zip</artifactoryPackageExtension> <wso2esbname>wso2esb</wso2esbname> <wso2esbversion>5.0.0</wso2esbversion> <wso2esbext>zip</wso2esbext> </properties> <groupId>com.test.cip.ff.platform</groupId> <artifactId>wso2mi</artifactId> <version>4.2.0-m1</version> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>3.2.0</version> <executions> <execution> <id>copy-dependencies</id> <phase>install</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory>${project.build.directory}/my-dependencies-directory</outputDirectory> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <executions> <execution> <phase>package</phase> <goals> <goal>single</goal> </goals> <configuration> <includeBaseDirectory>false</includeBaseDirectory> <appendAssemblyId>false</appendAssemblyId> <descriptors> <descriptor>${project.basedir}/assembly/zip.xml</descriptor> </descriptors> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <version>1.8</version> <executions> <!-- Change file permission for all files in dependency folder (Eg. installer) --> <execution> <id>build</id> <phase>validate</phase> <goals> <goal>run</goal> </goals> <configuration> <target> <echo>Creating directory for chmod command</echo> <mkdir dir="${project.build.directory}/dependency"/> <echo>Creating directory for chmod command</echo> <mkdir dir="${project.build.directory}/dependency/installer"/> <echo>run chmod in ${project.build.directory}</echo> <chmod file="${project.build.directory}/dependency" perm="ugo+rx"/> <chmod file="${project.build.directory}/dependency/**" perm="ugo+rx"/> <chmod file="${project.build.directory}/dependency/installer" perm="ugo+rx"/> </target> </configuration> </execution> <execution> <id>replace-tokens</id> <phase>compile</phase> <goals> <goal>run</goal> </goals> <configuration> <target name="replace-tokens"> <replace file="${project.build.directory}/bin/configure" token="@WSO2ESB_PACKAGE@" value="${wso2esbname}-${wso2esbversion}.${wso2esbext}"/> </target> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <version>1.8</version> <executions> <!-- Change file permission for all files in dependency folder (Eg. installer) --> <execution> <id>build</id> <phase>validate</phase> <goals> <goal>run</goal> </goals> <configuration> <target> <echo>run chmod in ${project.build.directory}</echo> <chmod file="${project.build.directory}/dependency" perm="ugo+rx"/> </target> </configuration> </execution> <!-- Replace tokens in file --> <execution> <id>replace-tokens</id> <phase>compile</phase> <goals> <goal>run</goal> </goals> <configuration> <target name="replace-tokens"> <replace file="${project.build.directory}/bin/configure" token="@WSO2ESB_PACKAGE@" value="${wso2esbname}-${wso2esbversion}.${wso2esbext}"/> </target> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>3.0.0</version> <executions> <execution> <id>run-ls-command</id> <goals> <goal>exec</goal> </goals> <configuration> <target> <echo>Logging a message from Maven!</echo> </target> <executable>ls</executable> <arguments> <argument>-lrt</argument> <argument>-R</argument> </arguments> </configuration> </execution> </executions> </plugin> <plugin> <artifactId>maven-resources-plugin</artifactId> <executions> <!-- Copy specification file to target directory --> <execution> <id>copy-specification</id> <phase>compile</phase> <goals> <goal>copy-resources</goal> </goals> <configuration> <outputDirectory>${project.build.directory}</outputDirectory> <resources> <resource> <directory>${project.basedir}/src/main/config</directory> <filtering>true</filtering> <include>wso2esb.specification</include> </resource> </resources> </configuration> </execution> <!-- Copy packinglist file to target directory --> <execution> <id>copy-packinglist</id> <phase>compile</phase> <goals> <goal>copy-resources</goal> </goals> <configuration> <outputDirectory>${project.build.directory}/resources</outputDirectory> <resources> <resource> <directory>${project.basedir}/src/main/config</directory> <filtering>true</filtering> <include>.packinglist</include> </resource> </resources> </configuration> </execution> <!-- Copy wso2esb configuration file to target directory --> <execution> <id>copy-wso2esb-config</id> <phase>compile</phase> <goals> <goal>copy-resources</goal> </goals> <configuration> <outputDirectory>${project.build.directory}/resources</outputDirectory> <resources> <resource> <directory>${project.basedir}/src/main/config</directory> <filtering>true</filtering> <include>wso2esb.config</include> </resource> </resources> </configuration> </execution> <!-- Copy wso2esb startup script to target directory --> <execution> <id>copy-startup-script</id> <phase>compile</phase> <goals> <goal>copy-resources</goal> </goals> <configuration> <outputDirectory>${project.build.directory}/resources</outputDirectory> <resources> <resource> <directory>${project.basedir}/src/main/config</directory> <filtering>true</filtering> <include>wso2esb_control.sh</include> </resource> </resources> </configuration> </execution> <!-- Copy validate & configure scripts to target directory --> <execution> <id>copy-installer-scripts</id> <phase>validate</phase> <goals> <goal>copy-resources</goal> </goals> <configuration> <outputDirectory>${project.build.directory}/bin</outputDirectory> <resources> <resource> <directory>${project.basedir}/src/main/bin</directory> <filtering>true</filtering> <include>validate</include> </resource> <resource> <directory>${project.basedir}/src/main/bin</directory> <filtering>true</filtering> <include>configure</include> </resource> </resources> </configuration> </execution> </executions> </plugin> </plugins> </build> <profiles> <profile> <id>unix</id> <activation> <os> <family>unix</family> </os> </activation> <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <!-- Build cpio package --> <executions> <execution> <id>build_package</id> <phase>package</phase> <goals> <goal>exec</goal> </goals> <configuration> <executable>${project.build.directory}/dependency/installer</executable> <arguments> <argument>${project.build.directory}/resources/.packinglist -cpio ${project.artifactId}-${project.version}.cpio -unlabelled -rdir ${project.build.directory}</argument> </arguments> </configuration> </execution> </executions> </plugin> <!--<plugin> <artifactId>maven-antrun-plugin</artifactId> <version>1.8</version> <executions> Rename cpio file <execution> <phase>package</phase> <configuration> <tasks> <move file="${project.build.directory}/UNLABELLED-${project.artifactId}-${project.version}.cpio.Z" tofile="${project.build.directory}/${project.artifactId}-${project.version}.cpio.Z"/> </tasks> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin> --> </plugins> </build> </profile> </profiles> </project> 但是 mvn clean install 因错误而失败 [ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (build_package) on project wso2mi: Command execution failed.: Cannot run program "/home/my_account/Desktop/CodeBase/test/test1/platform/target/dependency/installer" (in directory "/home/my_account/Desktop/CodeBase/test/test1/platform"): error=13, Permission denied 即使我尝试使用一个小型的基本 Maven,这也失败了 <?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> <!-- This is often your domain name (reversed.) --> <groupId>com.yourorganization</groupId> <!-- The name of this project (actually, the name of the artifact, which is the thing that this project produces. A jar in this case.) --> <artifactId>javaparser-maven-sample</artifactId> <!-- The version of this project. SNAPSHOT means "we're still working on it" --> <version>1.0-SNAPSHOT</version> <properties> <!-- Tell Maven we want to use Java 8 --> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <!-- Tell Maven to treat all source files as UTF-8 --> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <!-- Here are all your dependencies. Currently only one. These are automatically downloaded from https://mvnrepository.com/ --> <dependency> <groupId>com.github.javaparser</groupId> <artifactId>javaparser-core</artifactId> <version>3.25.3</version> </dependency> </dependencies> <!-- This blob of configuration tells Maven to make the jar executable. You can run it with: mvn clean package java -jar target/javaparser-maven-sample-1.0-SNAPSHOT-shaded.jar --> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>3.4.1</version> <executions> <execution> <goals> <goal>shade</goal> </goals> <configuration> <shadedArtifactAttached>true</shadedArtifactAttached> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <mainClass>com.yourorganization.maven_sample.LogicPositivizer</mainClass> </transformer> </transformers> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>3.2.0</version> <executions> <execution> <id>copy-dependencies</id> <phase>install</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory>${project.build.directory}/my-dependencies-directory</outputDirectory> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <!-- Build cpio package --> <executions> <execution> <id>build_package</id> <phase>package</phase> <goals> <goal>exec</goal> </goals> <configuration> <executable>${project.build.directory}/dependency/installer</executable> <arguments> <argument> ${project.build.directory}/resources/.packinglist -cpio ${project.artifactId}-${project.version}.cpio -unlabelled -rdir ${project.build.directory}</argument> </arguments> </configuration> </execution> </executions> </plugin> </plugins> </build> </project> 同样的错误 [ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.1.0:exec (build_package) on project javaparser-maven-sample: Command execution failed.: Cannot run program "C:\Users\subodhc\Downloads\javaparser-maven-sample-master\target\dependency\installer" (in directory "C:\Users\subodhc\Downloads\javaparser-maven-sample-master"): CreateProcess error=2, The system cannot find the file specified -> [Help 1]

回答 0 投票 0

maven maven-antrun-plugin插件是否也可以像maven-install-plugin一样运行

请参考https://maven.apache.org/plugins/maven-antrun-plugin/plugin-info.html 在 Maven 中使用 antrun 插件时,我似乎被迫在 build/plugins 中定义一个插件块。还有……

回答 0 投票 0

当通过 IDE 手动运行测试失败时,我如何确定 Maven 构建成功的原因?

我有以下设置: 阿帕奇行家 3.8.1 Maven 主页:/Users/deyb/.sdkman/candidates/maven/current Java 版本:1.8.0_342,供应商:Azul Systems, Inc.,运行时:/Users/myuser/.sdkman/candidate...

回答 1 投票 0

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