相关疑难解决方法(0)

Maven插件前缀解析如何工作?为什么要解决"findbugs"而不是"jetty"?

我正在使用Maven进行一些测试,并意识到我可以执行findbugsFindbugs插件的目标,而无需将插件添加到POM文件中.另一方面,当我需要运行runJetty插件的目标时,我被迫将插件添加到POM文件或构建失败.

  • 为什么Jetty需要在POM中配置而Findbugs没有?
  • Maven如何知道要执行哪个Findbugs(假设我们必须使用相同名称但不同组ID的插件)?

当我运行第一个命令时,构建成功,而POM文件没有任何更改:

mvn findbugs:findbugs
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building module-mytest 1.0
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- findbugs-maven-plugin:3.0.4:findbugs (default-cli) @ module-mytest ---
[INFO] Fork Value is true
     [java] Warnings generated: 6
[INFO] Done FindBugs Analysis....
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 24.165s
[INFO] Finished at: Sun Oct 23 18:40:26 WEST 2016
[INFO] Final Memory: 21M/111M
[INFO] -----------------------------------------------------------------------
Run Code Online (Sandbox Code Playgroud)

但是当我运行第二个时,我得到了这个:

mvn jetty:run
[INFO] Scanning for projects...
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metadata.xml
Downloading: …
Run Code Online (Sandbox Code Playgroud)

java maven maven-metadata

13
推荐指数
1
解决办法
3万
查看次数

使用地图的地图作为 Maven 插件参数

是否可以使用地图的地图作为 Maven 插件参数?,例如

@Parameter
private Map<String, Map<String, String>> converters;
Run Code Online (Sandbox Code Playgroud)

然后像这样使用它

<converters>
  <json>
     <indent>true</indent>
     <strict>true</strict>
  </json>
  <yaml>
      <stripComments>false</stripComments>
  </yaml>
<converters>
Run Code Online (Sandbox Code Playgroud)

如果我像这样使用它,converters则仅包含键json并yaml以 null 作为值。

我知道可以将复杂的对象作为值,但是是否也可以像本示例中那样使用映射作为变量元素值?

maven-plugin maven

4
推荐指数
1
解决办法
2375
查看次数

Maven:使用指定主类和属性文件的 shade-plugin 编译项目

Maven 新手,我试图使用 Maven 和 maven-shade-plugin 编译一个项目(因为它似乎是构建一个胖 jar 的最佳插件)。我试图指定我的主类来制作一个可运行的 jar 文件和一些包含翻译字符串的 .properties 文件。

根据 netbeans 输出,编译和构建似乎已通过,但我无法按以下方式运行它(假设由 Maven 构建的 jar 重命名为“程序”):

/usr/bin/java -cp program.jar bot.Main
> could not find or load main class bot.Main
Run Code Online (Sandbox Code Playgroud)

这是我的项目文件结构:

项目文件

这是我的 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>com.mycompany</groupId>
<artifactId>mavenproject1</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<build>
    <resources>
    <resource>
        <directory>src/main/java/resources</directory>
        <includes>
            <include>**/*.properties</include>
        </includes>
    </resource>
</resources>
<plugins>

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>2.4.3</version>
    <configuration>
      <archive>
      <manifest>
        <addClasspath>true</addClasspath>
        <classpathPrefix>lib/</classpathPrefix>
        <mainClass>bot.Main</mainClass>
      </manifest>
    </archive>
    <shadedArtifactAttached>true</shadedArtifactAttached>
    <shadedClassifierName>launcher</shadedClassifierName>
    </configuration>
    <executions>
      <execution>
        <phase>package</phase>
        <goals>
          <goal>shade</goal>
        </goals> …
Run Code Online (Sandbox Code Playgroud)

java maven maven-shade-plugin

3
推荐指数
1
解决办法
6025
查看次数