请参阅下面的pom.xml中的插件配置.
我可以:
mvn myplugin:myGoal
哪个运行myGoal(我认为都是执行)但我希望能够独立选择第一个或第二个执行.
我知道我可以在执行元素中添加一个id,但是如何在命令行中引用该id.我想得到一些能够完成这个想象命令的功能:
mvn myplugin:myGoal --executionId=1
这是可能的,还是我以错误的方式解决这个问题?
<plugin>
<groupId>org.myplugin</groupId>
<artifactId>myplugin-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<goals>
<goal>myGoal</goal>
</goals>
<configuration>
<myParam>cats</myParam>
</configuration>
</execution>
<execution>
<goals>
<goal>myGoal</goal>
</goals>
<configuration>
<myParam>dogs</myParam>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud) 我正在使用STS,我从另一台机器上导入了一个GWT项目.该项目使用m2eclipse.我在构建项目时遇到了这两个错误:
Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:gwt-maven-plugin:2.2.0:i18n (execution: default, phase: generate-sources) pom.xml /contactsgwt line 175
Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-war-plugin:2.1.1:exploded (execution: default, phase: compile) pom.xml /contactsgwt line 198
Run Code Online (Sandbox Code Playgroud)
怎么了?有没有进一步的配置需要这样做才能gwt maven plugin
工作?
pom.xml
导致错误的代码:
<!-- GWT Maven Plugin -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.2.0</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test</goal>
<goal>i18n</goal>
</goals>
</execution>
</executions>
<!-- Plugin configuration. There are many available options, see gwt-maven-plugin documentation at codehaus.org -->
<configuration>
<runTarget>Contacts.html</runTarget>
<hostedWebapp>${webappDirectory}</hostedWebapp
<i18nMessagesBundle>es.indra.gwt.contactsgwt.client.ContactsMessages</i18nMessagesBundle>
</configuration>
</plugin>
<!-- Copy …
Run Code Online (Sandbox Code Playgroud) 这是它目前的工作方式,它是Maven Deploy Plugin Usage
的pom.xml
[...]
<distributionManagement>
<repository>
<id>internal.repo</id>
<name>MyCo Internal Repository</name>
<url>Host to Company Repository</url>
</repository>
</distributionManagement>
[...]
Run Code Online (Sandbox Code Playgroud)
的settings.xml
[...]
<server>
<id>internal.repo</id>
<username>someUser</username>
<password>somePassword</password>
</server>
[...]
Run Code Online (Sandbox Code Playgroud)
而我正在努力实现的是找到一种在命令行输入用户名和密码的方法.实现mvn deploy -someUser -somePassword
我正在研究一个maven插件.我似乎很难搞清楚,从执行MOJO的项目中获取POM信息的好方法是什么?
例如,如果我在另一个maven项目中执行我的mojo,我想获得项目名称或其他一些参数.
还有一件事,在AbstractMojo.java类中有一个上下文MAP有私有Map pluginContext,如果我错了可能会有人纠正我,但这是假设用于在mojos之间传递信息吗?
我在Windows环境中使用maven编译我的项目.虽然我刚刚创建了项目并添加了各种库的依赖项.
当我添加它们时,maven开始抱怨失踪tools.jar
,所以我在下面添加到我的pom.xml
:
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.6</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
Run Code Online (Sandbox Code Playgroud)
当我运行maven安装时,我得到了丢失jar的错误,如下所示:
[ERROR] Failed to execute goal on project GApp: Could not resolve dependencies for project GApp:GApp:war:0.0.1-SNAPSHOT: Could not find artifact com.sun:tools:jar:1.6 at specified path C:\Program Files\Java\jre6\lib\tools.jar -> [Help 1]
Run Code Online (Sandbox Code Playgroud)
问题是它tools.jar
在" C:\Program Files\Java\jdk1.6.0_26\lib
"中并且在JAVA_HOME
环境变量中正确设置但是maven仍然在jre文件夹中查找错误消息" C:\Program Files\Java\jre6\lib\tools.jar
".
C:\>echo %JAVA_HOME%
C:\Program Files\Java\jdk1.6.0_26
Run Code Online (Sandbox Code Playgroud)
有趣的是:当我设置依赖的完整路径时,它工作得很好.但我不想硬编码.
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.6</version>
<scope>system</scope>
<systemPath>C:\Program Files\Java\jdk1.6.0_26\lib\tools.jar</systemPath>
</dependency>
Run Code Online (Sandbox Code Playgroud)
有人可以建议任何动态解决方案吗?
我有两个顶级Maven项目,backend
并且frontend
以各自的速度推进版本.由于每个模块都有多个模块,因此我dependencyManagement
在父/聚合POM 中的部分中定义了我的依赖项版本,并使用属性作为版本号.
我想用版本号干净地更新属性frontend
,最好随意更新,但我可以忍受要求实时上游版本匹配.我尝试过使用versions:update-property
,但这个目标似乎完全不起作用; 无论是否真的有匹配的上游版本,我得到这个调试输出:
$ mvn versions:update-property -Dproperty=frontend.version -DnewVersion=0.13.2 -DautoLinkItems=false -X
...
[DEBUG] Searching for properties associated with builders
[DEBUG] Property ${frontend.version}
[DEBUG] Property ${frontend.version}: Looks like this property is not associated with any dependency...
[DEBUG] Property ${frontend.version}: Set of valid available versions is [0.9.0, 0.9.1, 0.9.2, 0.9.3, 0.9.4, 0.9.5, 0.10.0, 0.10.1, 0.11.0, 0.12.0, 0.13.0, 0.13.1, 0.13.2, 0.13.3]
[DEBUG] Property ${frontend.version}: Restricting results to 0.13.2
[DEBUG] Property ${frontend.version}: Current winner …
Run Code Online (Sandbox Code Playgroud) 我的日食是Indigo Java classic.
我有一个java项目,它有mockito-all作为依赖项.pom.xml中:
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.8.5</version>
<scope>test</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
跑mvn clean install
,一切都好.然后我做mvn eclipse:eclipse
了解决Eclipse中的所有依赖项.
当我尝试在eclipse中运行Junit时,它不会运行并给我这个错误:
'Launching YourTest' has encountered a problem.
The archive: /home/shengjie/.m2/repository/org/mockito/mockito-all/1.9.5.jar which is referenced by the classpath, does not exist.
Run Code Online (Sandbox Code Playgroud)
我的项目pom.xml声称它取决于mockito-all 1.8.5,我不确定1.9.5引用的来源.有任何想法吗?
== ==编辑
$ mvn dependency:tree | grep mockito
[INFO] +- org.mockito:mockito-all:jar:1.8.5:test
[INFO] \- org.powermock:powermock-api-mockito:jar:1.4.12:test
[INFO] \- org.powermock:powermock-api-mockito:jar:1.4.12:test
[INFO] +- org.mockito:mockito-all:jar:1.8.5:test (version managed from 1.9.0)
[INFO] | +- org.mockito:mockito-all:jar:1.8.5:test (version managed from 1.9.5; scope managed from compile)
[INFO] | +- org.mockito:mockito-all:jar:1.8.5:test (version …
Run Code Online (Sandbox Code Playgroud) 我正在使用maven 3来运行应用程序,但是我收到以下错误:
[ERROR] The build could not read 1 project -> [Help 1]
org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM: Failure to find com.topdesk:tis-parent:pom:3.
4 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM @ line 3, column 11
at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:416)
at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:663)
at org.apache.maven.DefaultMaven.getProjectsForMavenReactor(DefaultMaven.java:654)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:243)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:582) …
Run Code Online (Sandbox Code Playgroud) 我正在使用buildnumber-maven-plugin将Mercurial变更集作为项目内部版本号:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>hgchangeset</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
然后我使用${changeSet}
property来设置build.number
属性pom.xml
:
<build.number>${changeSet}</build.number>
Run Code Online (Sandbox Code Playgroud)
但是,IntelliJ IDEA抱怨它Cannot resolve symbol 'changeSet'
:
此外,模块根目录和受影响的pom.xml
文件在"项目"工具窗口中以红色下划线.
我在设置中尝试了所有提供的Alt+Enter选项和Maven配置; 没什么帮助.
一切都建立和工作正常,我只是想摆脱IDE中显示的恼人的错误.有什么建议吗?
IDE和环境:
IntelliJ IDEA 2016.1.2
Build #IC-145.972, built on May 14, 2016
JRE: 1.8.0_65-b17 amd64
JVM: Java HotSpot(TM) 64-Bit Server VM by Oracle Corporation
Run Code Online (Sandbox Code Playgroud) <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.springframework.samples.service.service</groupId>
<artifactId>localgame</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<!-- Generic properties -->
<java.version>1.6</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!-- Web -->
<jsp.version>2.2</jsp.version>
<jstl.version>1.2</jstl.version>
<servlet.version>2.5</servlet.version>
<!-- Spring -->
<spring-framework.version>3.2.3.RELEASE</spring-framework.version>
<!-- Hibernate / JPA -->
<hibernate.version>4.2.1.Final</hibernate.version>
<!-- Logging -->
<logback.version>1.0.13</logback.version>
<slf4j.version>1.7.5</slf4j.version>
<!-- Test -->
<junit.version>4.11</junit.version>
</properties>
<dependencies>
<!-- Spring MVC -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring-framework.version}</version>
</dependency>
<!-- Other Web dependencies -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>${jstl.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>${servlet.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>${jsp.version}</version>
<scope>provided</scope>
</dependency>
<!-- Spring and Transactions …
Run Code Online (Sandbox Code Playgroud)