我使用Eclipse,对于我的一些单元测试,我需要为测试设置一些JVM args,-Djava.library.path特别是.我在POM文件中设置如下:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Djava.library.path=target/dll</argLine>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
当我使用Maven构建时,它可以正常工作.但是,当我在Eclipse中运行时(即使安装了Maven插件 - 我的Eclipse环境中的其他所有内容都与maven一起正常工作),此JVM参数未应用.有谁知道这是为什么或如何解决这个问题?
在我们公司,我们正在使用本地nexus存储库.如果我现在尝试使用eclipse项目向导(安装了M2Eclipse 0.12.1)创建一个新的Maven项目,我总是从nexus得到503错误.
org.eclipse.core.runtime.CoreException: Could not resolve artifact
at org.maven.ide.eclipse.internal.embedder.MavenImpl.resolve(MavenImpl.java:577)
at org.maven.ide.eclipse.internal.project.ProjectConfigurationManager.resolveArchetype(ProjectConfigurationManager.java:526)
at org.maven.ide.eclipse.internal.project.ProjectConfigurationManager.createArchetypeProject(ProjectConfigurationManager.java:437)
at org.maven.ide.eclipse.wizards.MavenProjectWizard$5.runInWorkspace(MavenProjectWizard.java:279)
at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Contains: Could not transfer artifact org.apache.maven.archetypes:maven-archetype-quickstart:pom:1.0-alpha-4 from/to nexus (http://vm-nexus-slx.heuboe.hbintern:8080/nexus/content/groups/public): Failed to transfer http://vm-nexus-slx.heuboe.hbintern:8080/nexus/content/groups/public/org/apache/maven/archetypes/maven-archetype-quickstart/1.0-alpha-4/maven-archetype-quickstart-1.0-alpha-4.pom. Error code 503, Service Unavailable
org.sonatype.aether.transfer.ArtifactTransferException: Could not transfer artifact org.apache.maven.archetypes:maven-archetype-quickstart:pom:1.0-alpha-4 from/to nexus (http://vm-nexus-slx.heuboe.hbintern:8080/nexus/content/groups/public): Failed to transfer http://vm-nexus-slx.heuboe.hbintern:8080/nexus/content/groups/public/org/apache/maven/archetypes/maven-archetype-quickstart/1.0-alpha-4/maven-archetype-quickstart-1.0-alpha-4.pom. Error code 503, Service Unavailable
at org.sonatype.aether.connector.async.AsyncRepositoryConnector$3.wrap(AsyncRepositoryConnector.java:1413)
at org.sonatype.aether.connector.async.AsyncRepositoryConnector$3.wrap(AsyncRepositoryConnector.java:1404)
at org.sonatype.aether.connector.async.AsyncRepositoryConnector$GetTask.flush(AsyncRepositoryConnector.java:895)
at org.sonatype.aether.connector.async.AsyncRepositoryConnector$GetTask.flush(AsyncRepositoryConnector.java:889)
at org.sonatype.aether.connector.async.AsyncRepositoryConnector.get(AsyncRepositoryConnector.java:276)
at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:438)
at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:214)
at org.sonatype.aether.impl.internal.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:296)
at org.maven.ide.eclipse.internal.embedder.MavenImpl.resolve(MavenImpl.java:555)
at org.maven.ide.eclipse.internal.project.ProjectConfigurationManager.resolveArchetype(ProjectConfigurationManager.java:526)
at org.maven.ide.eclipse.internal.project.ProjectConfigurationManager.createArchetypeProject(ProjectConfigurationManager.java:437)
at org.maven.ide.eclipse.wizards.MavenProjectWizard$5.runInWorkspace(MavenProjectWizard.java:279)
at …Run Code Online (Sandbox Code Playgroud) 问题:
我想在我使用m2eclipse打包的jar文件中指定主类:[右键单击] - >运行方式 - > Maven包.我还在学习Maven,从我读过的内容来看,完成这项任务的直接方法是在pom.xml中添加一个节.
以下是我在研究此问题时发现的示例:
我的问题是:可以使用文本编辑器手动编辑Eclipse/m2eclipse之外的pom.xml文件,还是应该使用m2ecplise GUI进行此配置?有几个选项卡式对话框似乎可能是此任务的候选对象,如"插件"和"构建".我查看了Sonatype的文档,找不到有关如何完成我需要做的任何详细说明.
我有点犹豫要手动编辑pom.xml因为我注意到"Effective POM"已经有很多额外的东西,包括需要添加到它的插件定义:
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>default-jar</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
如果我理解正确,需要更改有效POM,以便插件配置如下:
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>default-jar</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
<manifest>
<mainClass>[name of main class]</mainClass>
<packageName>[package name]</packageName>
</manifest>
<manifestEntries>
<mode>development</mode>
<url>${pom.url}</url>
</manifestEntries>
</archive>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
这是正确的吗?如果是这样,我是否通过m2eclipse执行此操作,还是应该复制所有额外的有效POM内容并使用文本编辑器将其粘贴到实际的pom.xml中?
感谢任何能够解决问题的人.
更新:我继续在文本编辑器中手动编辑pom.xml文件.当我在m2eclipse中查看Effective POM时,它会显示我放入的所有内容(我假设).我构建了jar并且正确设置了主类.
这对我来说似乎是个黑客.有没有人知道是否有办法使用m2eclipse本身进行此配置?我检查了m2eclipse选项卡,由于我对pom.xml的手动编辑(除了Effective POM选项卡),似乎没有更新任何内容.
m2e不再适用于我的Eclipse Indigo.没有任何内容打印到Maven控制台,我无法下载任何源代码,一些依赖项将无法解决.我正在使用嵌入式Maven安装.
你知道如何解决这个问题吗?
我正在使用Maven和Assembly插件,并希望为tar文件设置用户和组.
我可以设置每个目录的访问权限,但没有设置用户这是没用的.
有任何想法吗?
我不得不重新安装我的Eclipse,现在我必须将所有现有项目导入新工作区.以前版本的Eclipse是Galileo,这个版本是Indigo.插件已安装,但在"导入现有Maven项目"之后,项目未显示为WTP(WebApp项目)...
我是否需要其他设置或配置?
非常感谢!
我做了一个maven项目,它工作得很好.然后我安装了插件EclEmma Java Code Coverage,PHP开发工具(PDT),Eclipse.orgSonarQube
然后我参与了其他一些项目.当我再次想要创建一个maven项目时,它抛出了以下错误窗口
The selected wizard could not be started
reason
plug-in org.eclipse.m2e.core.ui was unable to load class
org.eclipse.m2e.core.ui.internal wizards.MavenProjectWizard
Run Code Online (Sandbox Code Playgroud) 我正在通过Eclipse在Maven Web项目中工作.在web.xml,我有一个context-param,其值应根据我运行Maven时使用的配置文件而改变.
<context-param>
<param-name>producao</param-name>
<param-value>${ambiente.producao}</param-value>
</context-param>
Run Code Online (Sandbox Code Playgroud)
在项目的pom文件中,我有以下配置:
<project>
<profiles>
<profile>
<id>prod</id>
<properties>
<ambiente.producao>true</ambiente.producao>
</properties>
</profile>
<profile>
<id>desenv</id>
<properties>
<ambiente.producao>false</ambiente.producao>
</properties>
</profile>
</profiles>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/webapp/WEB-INF/</directory>
<filtering>true</filtering>
<includes>
<include>**/web.xml</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.5</version>
<configuration>
<webResources>
<resource>
<filtering>true</filtering>
<directory>src/main/webapp</directory>
<includes>
<include>**/web.xml</include>
</includes>
</resource>
</webResources>
<warSourceDirectory>src/main/webapp</warSourceDirectory>
<webXml>src/main/webapp/WEB-INF/web.xml</webXml>
</configuration>
</plugin>
</plugins>
</build>
</project>
Run Code Online (Sandbox Code Playgroud)
我resources根据我在互联网上找到的参考资料使用两个标签作为maven-war-plugin插件.但是,它没有按预期工作.在Eclipse中,我运行目标为clean install的maven,以及prod或desenv作为"Profiles" .在我运行Maven后,我观察到,在web.xml该${ambiente.producao}属性中没有被替换.因此,我想知道我做错了什么.我应该只使用Filtering资源还是maven-war-plugin?
谢谢,
Rafael Afonso
有没有办法使我的所有src/main/resources/文件夹都具有“平面视图”而不是“树视图”?
我使用的是M2Eclipse,它排除了它们(不包括**)。当然,有某种方法可以只更改首选项中的视图选项,而不是从每个项目中删除它?还是有将其删除的M2Eclipse设置?
以下是我对树状视图和平面视图的解释:
树视图
v com
v stackoverflow
v example
file1.xml
file2.xml
v weNeedToGoDeeper
file3.xml
file4.xml
> someClosedFolder
Run Code Online (Sandbox Code Playgroud)平面视图
v com.stackoverflow.example
file1.xml
file2.xml
v com.stackoverflow.example.weNeedToGoDeeper
file3.xml
file4.xml
> com.stackoverflow.example.someClosedFolder
Run Code Online (Sandbox Code Playgroud)我花了一段时间来做这个观察,但我看到m2e"神奇地"管理了类路径.
示例:如果我在"src/java/main"源文件夹中作为Java应用程序运行,则它将排除"test"范围.注意:该类能够编译,但无法运行.但是,如果我将同一个类移动到"src/java/test"文件夹,那么它就能够编译并运行.
如果我Run as JUnit Test那么总是包含"测试"范围(即使该类在"主"源文件夹中).
我发现这些发现的唯一方法是在运行时转储java.class.path系统属性.
我在http://www.eclipse.org/m2e/documentation/m2e-faq.html上找到了以下内容
另请注意,用于启用Maven支持的项目的JUnit和Java Application启动配置的类路径也以特殊方式计算,排除的资源也不会影响它.
当我比较他们的运行配置时,我看不出任何差异,那么我怎样才能看到正在执行的魔术?
有没有办法通过运行配置或任何其他方式覆盖"正常"行为?