java Maven警告-不太清楚

u4dcyp6a  于 2023-01-04  发布在  Java
关注(0)|答案(3)|浏览(173)

我有以下maven文件,构建完成,但有警告,我无法理解原因:
4.0.0 io.javabrains junit-5-基础知识0.0.1-快照junit-5-基础知识Java Brains(javabrains. io)上的JUnit 5基础知识课程附带的代码

<properties>
    <maven.compiler.target>11</maven.compiler.target>
    <maven.compiler.source>11</maven.compiler.source>
    <junit.jupiter.version>5.4.0</junit.jupiter.version>
    <dependency-check-maven.version>7.3.0</dependency-check-maven.version>
    <sonar.dependencyCheck.htmlReportPath>./target/dependency-check-report.html</sonar.dependencyCheck.htmlReportPath>
    <sonar.dependencyCheck.jsonReportPath>./target/dependency-check-report.json</sonar.dependencyCheck.jsonReportPath>
    <sonar.dependencyCheck.summarize>true</sonar.dependencyCheck.summarize>
</properties>

<dependencies>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>${junit.jupiter.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-api</artifactId>
        <version>${junit.jupiter.version}</version>
        <scope>test</scope>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.22.1</version>
        </plugin>
        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.8.9-SNAPSHOT</version>
                                          
            <executions>
                <execution>
                    <id>prepare-agent</id>
                    <goals><goal>prepare-agent</goal></goals>
                </execution>
                <execution>
                    <id>report</id>
                    <phase>test</phase>
                    <goals><goal>report</goal></goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.owasp</groupId>
            <artifactId>dependency-check-maven</artifactId>
            <version>${dependency-check-maven.version}</version>
            
            <configuration>
                <formats>
                    <format>html</format>
                    <format>json</format>
                </formats>
            </configuration>
            <executions>
              <execution>
                  <goals>
                      <goal>check</goal>
                  </goals>
                </execution>
            </executions>
        </plugin>

    </plugins>
</build>

我收到以下警告
构建io的有效模型时遇到了一些问题。javabrains:junit-5-basics:jar:0.0.1-SNAPSHOT [警告]“build.plugins.plugin.(groupId:artifactId)”必须唯一,但发现插件org的重复声明。jacoco:jacoco-maven-plugin @第76行第15列[警告] [警告]强烈建议修复这些问题,因为它们威胁到构建的稳定性。[警告][警告]因此,未来的Maven版本可能不再支持构建此类格式错误的项目。[警告] [警告]构件org.codehaus.mojo:sonar-maven-plugin:jar:3.9.1.2184已重新定位到org.sonarsource.scanner.maven:sonar-maven-plugin:jar:3.9.1.2184:SonarQube插件已移至SonarSource组织[信息]
在第76行,实际上没有groupId:artifactId的重复,如果我没有弄错的话,我遵守了说明。
[警告]工件org.codehaus.mojo:sonar-maven-plugin:jar
因为pom文件中没有提到任何关于codehaus的内容。此构建在Azure管道maven构建中运行

7tofc5zh

7tofc5zh1#

对不起@Khmarbaise我错误地应用了mvn帮助:在本地而不是在repo中的有效pom,这里是正确的有效POM

<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>io.javabrains</groupId>
  <artifactId>junit-5-basics</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>junit-5-basics</name>
  <description>Code accompanying the JUnit 5 Basics course on Java Brains (javabrains.io)</description>
  <properties>
    <maven.compiler.source>11</maven.compiler.source>
    <sonar.dependencyCheck.htmlReportPath>./target/dependency-check-report.html</sonar.dependencyCheck.htmlReportPath>
    <junit.jupiter.version>5.4.0</junit.jupiter.version>
    <dependency-check-maven.version>7.3.0</dependency-check-maven.version>
    <maven.compiler.target>11</maven.compiler.target>
    <sonar.dependencyCheck.jsonReportPath>./target/dependency-check-report.json</sonar.dependencyCheck.jsonReportPath>
    <sonar.dependencyCheck.summarize>true</sonar.dependencyCheck.summarize>
  </properties>
  <dependencies>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-engine</artifactId>
      <version>5.4.0</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-api</artifactId>
      <version>5.4.0</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <repositories>
    <repository>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>central</id>
      <name>Central Repository</name>
      <url>https://repo.maven.apache.org/maven2</url>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <releases>
        <updatePolicy>never</updatePolicy>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>central</id>
      <name>Central Repository</name>
      <url>https://repo.maven.apache.org/maven2</url>
    </pluginRepository>
  </pluginRepositories>
  <build>
    <sourceDirectory>C:\Projects\Workspace-Eclipse-Junit\junit-5-basics-course\src\main\java</sourceDirectory>
    <scriptSourceDirectory>C:\Projects\Workspace-Eclipse-Junit\junit-5-basics-course\src\main\scripts</scriptSourceDirectory>
    <testSourceDirectory>C:\Projects\Workspace-Eclipse-Junit\junit-5-basics-course\src\test\java</testSourceDirectory>
    <outputDirectory>C:\Projects\Workspace-Eclipse-Junit\junit-5-basics-course\target\classes</outputDirectory>
    <testOutputDirectory>C:\Projects\Workspace-Eclipse-Junit\junit-5-basics-course\target\test-classes</testOutputDirectory>
    <resources>
      <resource>
        <directory>C:\Projects\Workspace-Eclipse-Junit\junit-5-basics-course\src\main\resources</directory>
      </resource>
    </resources>
    <testResources>
      <testResource>
        <directory>C:\Projects\Workspace-Eclipse-Junit\junit-5-basics-course\src\test\resources</directory>
      </testResource>
    </testResources>
    <directory>C:\Projects\Workspace-Eclipse-Junit\junit-5-basics-course\target</directory>
    <finalName>junit-5-basics-0.0.1-SNAPSHOT</finalName>
    <pluginManagement>
      <plugins>
        <plugin>
          <artifactId>maven-antrun-plugin</artifactId>
          <version>1.3</version>
        </plugin>
        <plugin>
          <artifactId>maven-assembly-plugin</artifactId>
          <version>2.2-beta-5</version>
        </plugin>
        <plugin>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>2.8</version>
        </plugin>
        <plugin>
          <artifactId>maven-release-plugin</artifactId>
          <version>2.5.3</version>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.22.1</version>
        <executions>
          <execution>
            <id>default-test</id>
            <phase>test</phase>
            <goals>
              <goal>test</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>0.8.9-SNAPSHOT</version>
        <executions>
          <execution>
            <id>prepare-agent</id>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
          </execution>
          <execution>
            <id>report</id>
            <phase>test</phase>
            <goals>
              <goal>report</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.owasp</groupId>
        <artifactId>dependency-check-maven</artifactId>
        <version>7.3.0</version>
        <executions>
          <execution>
            <goals>
              <goal>check</goal>
            </goals>
            <configuration>
              <formats>
                <format>html</format>
                <format>json</format>
              </formats>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <formats>
            <format>html</format>
            <format>json</format>
          </formats>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-clean-plugin</artifactId>
        <version>2.5</version>
        <executions>
          <execution>
            <id>default-clean</id>
            <phase>clean</phase>
            <goals>
              <goal>clean</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.6</version>
        <executions>
          <execution>
            <id>default-testResources</id>
            <phase>process-test-resources</phase>
            <goals>
              <goal>testResources</goal>
            </goals>
          </execution>
          <execution>
            <id>default-resources</id>
            <phase>process-resources</phase>
            <goals>
              <goal>resources</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-jar-plugin</artifactId>
        <version>2.4</version>
        <executions>
          <execution>
            <id>default-jar</id>
            <phase>package</phase>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <executions>
          <execution>
            <id>default-compile</id>
            <phase>compile</phase>
            <goals>
              <goal>compile</goal>
            </goals>
          </execution>
          <execution>
            <id>default-testCompile</id>
            <phase>test-compile</phase>
            <goals>
              <goal>testCompile</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-install-plugin</artifactId>
        <version>2.4</version>
        <executions>
          <execution>
            <id>default-install</id>
            <phase>install</phase>
            <goals>
              <goal>install</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-deploy-plugin</artifactId>
        <version>2.7</version>
        <executions>
          <execution>
            <id>default-deploy</id>
            <phase>deploy</phase>
            <goals>
              <goal>deploy</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-site-plugin</artifactId>
        <version>3.3</version>
        <executions>
          <execution>
            <id>default-site</id>
            <phase>site</phase>
            <goals>
              <goal>site</goal>
            </goals>
            <configuration>
              <outputDirectory>C:\Projects\Workspace-Eclipse-Junit\junit-5-basics-course\target\site</outputDirectory>
              <reportPlugins>
                <reportPlugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-project-info-reports-plugin</artifactId>
                </reportPlugin>
              </reportPlugins>
            </configuration>
          </execution>
          <execution>
            <id>default-deploy</id>
            <phase>site-deploy</phase>
            <goals>
              <goal>deploy</goal>
            </goals>
            <configuration>
              <outputDirectory>C:\Projects\Workspace-Eclipse-Junit\junit-5-basics-course\target\site</outputDirectory>
              <reportPlugins>
                <reportPlugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-project-info-reports-plugin</artifactId>
                </reportPlugin>
              </reportPlugins>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <outputDirectory>C:\Projects\Workspace-Eclipse-Junit\junit-5-basics-course\target\site</outputDirectory>
          <reportPlugins>
            <reportPlugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-project-info-reports-plugin</artifactId>
            </reportPlugin>
          </reportPlugins>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <reporting>
    <outputDirectory>C:\Projects\Workspace-Eclipse-Junit\junit-5-basics-course\target\site</outputDirectory>
  </reporting>
</project>
mwg9r5ms

mwg9r5ms2#

尝试管道中的POM文件,当使用jacoco-maven-plugin版本0.8.9-SNAPSHOT时,我们必须为插件仓库启用snapshots

但是,当运行管道时,由于org.jacoco:jacoco-maven-plugin:jar:0.8.9-SNAPSHOT的POM丢失,没有可用的依赖关系信息,因此管道失败并显示以下错误消息。

Plugin org.jacoco:jacoco-maven-plugin:0.8.9-SNAPSHOT or one of its dependencies could not be resolved: Could not find artifact org.jacoco:jacoco-maven-plugin:jar:0.8.9-SNAPSHOT in central (https://repo.maven.apache.org/maven2)

不过,在将插件版本更改为<version>0.8.8</version>后,它仍然可以工作。以下POM供您参考:

<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>io.javabrains</groupId>
  <artifactId>junit-5-basics</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>junit-5-basics</name>
  <description>Code accompanying the JUnit 5 Basics course on Java Brains (javabrains.io)</description>
  <properties>
    <maven.compiler.source>11</maven.compiler.source>
    <sonar.dependencyCheck.htmlReportPath>./target/dependency-check-report.html</sonar.dependencyCheck.htmlReportPath>
    <junit.jupiter.version>5.4.0</junit.jupiter.version>
    <dependency-check-maven.version>7.3.0</dependency-check-maven.version>
    <maven.compiler.target>11</maven.compiler.target>
    <sonar.dependencyCheck.jsonReportPath>./target/dependency-check-report.json</sonar.dependencyCheck.jsonReportPath>
    <sonar.dependencyCheck.summarize>true</sonar.dependencyCheck.summarize>
  </properties>
  <dependencies>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-engine</artifactId>
      <version>5.4.0</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-api</artifactId>
      <version>5.4.0</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <repositories>
    <repository>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
      <id>central</id>
      <name>Central Repository</name>
      <url>https://repo.maven.apache.org/maven2</url>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <releases>
        <updatePolicy>never</updatePolicy>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
      <id>central</id>
      <name>Central Repository</name>
      <url>https://repo.maven.apache.org/maven2</url>
    </pluginRepository>
  </pluginRepositories>
  <build>
    <sourceDirectory>C:\Projects\Workspace-Eclipse-Junit\junit-5-basics-course\src\main\java</sourceDirectory>
    <scriptSourceDirectory>C:\Projects\Workspace-Eclipse-Junit\junit-5-basics-course\src\main\scripts</scriptSourceDirectory>
    <testSourceDirectory>C:\Projects\Workspace-Eclipse-Junit\junit-5-basics-course\src\test\java</testSourceDirectory>
    <outputDirectory>C:\Projects\Workspace-Eclipse-Junit\junit-5-basics-course\target\classes</outputDirectory>
    <testOutputDirectory>C:\Projects\Workspace-Eclipse-Junit\junit-5-basics-course\target\test-classes</testOutputDirectory>
    <resources>
      <resource>
        <directory>C:\Projects\Workspace-Eclipse-Junit\junit-5-basics-course\src\main\resources</directory>
      </resource>
    </resources>
    <testResources>
      <testResource>
        <directory>C:\Projects\Workspace-Eclipse-Junit\junit-5-basics-course\src\test\resources</directory>
      </testResource>
    </testResources>
    <directory>C:\Projects\Workspace-Eclipse-Junit\junit-5-basics-course\target</directory>
    <finalName>junit-5-basics-0.0.1-SNAPSHOT</finalName>
    <pluginManagement>
      <plugins>
        <plugin>
          <artifactId>maven-antrun-plugin</artifactId>
          <version>1.3</version>
        </plugin>
        <plugin>
          <artifactId>maven-assembly-plugin</artifactId>
          <version>2.2-beta-5</version>
        </plugin>
        <plugin>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>2.8</version>
        </plugin>
        <plugin>
          <artifactId>maven-release-plugin</artifactId>
          <version>2.5.3</version>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.22.1</version>
        <configuration>
          <argLine>@{argLine} -more -arguments</argLine>
        </configuration>
        <executions>
          <execution>
            <id>default-test</id>
            <phase>test</phase>
            <goals>
              <goal>test</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>0.8.8</version>
        <executions>
          <execution>
            <id>prepare-agent</id>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
          </execution>
          <execution>
            <id>report</id>
            <phase>test</phase>
            <goals>
              <goal>report</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.owasp</groupId>
        <artifactId>dependency-check-maven</artifactId>
        <version>7.3.0</version>
        <executions>
          <execution>
            <goals>
              <goal>check</goal>
            </goals>
            <configuration>
              <formats>
                <format>html</format>
                <format>json</format>
              </formats>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <formats>
            <format>html</format>
            <format>json</format>
          </formats>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-clean-plugin</artifactId>
        <version>2.5</version>
        <executions>
          <execution>
            <id>default-clean</id>
            <phase>clean</phase>
            <goals>
              <goal>clean</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.6</version>
        <executions>
          <execution>
            <id>default-testResources</id>
            <phase>process-test-resources</phase>
            <goals>
              <goal>testResources</goal>
            </goals>
          </execution>
          <execution>
            <id>default-resources</id>
            <phase>process-resources</phase>
            <goals>
              <goal>resources</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-jar-plugin</artifactId>
        <version>2.4</version>
        <executions>
          <execution>
            <id>default-jar</id>
            <phase>package</phase>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <executions>
          <execution>
            <id>default-compile</id>
            <phase>compile</phase>
            <goals>
              <goal>compile</goal>
            </goals>
          </execution>
          <execution>
            <id>default-testCompile</id>
            <phase>test-compile</phase>
            <goals>
              <goal>testCompile</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-install-plugin</artifactId>
        <version>2.4</version>
        <executions>
          <execution>
            <id>default-install</id>
            <phase>install</phase>
            <goals>
              <goal>install</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-deploy-plugin</artifactId>
        <version>2.7</version>
        <executions>
          <execution>
            <id>default-deploy</id>
            <phase>deploy</phase>
            <goals>
              <goal>deploy</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-site-plugin</artifactId>
        <version>3.3</version>
        <executions>
          <execution>
            <id>default-site</id>
            <phase>site</phase>
            <goals>
              <goal>site</goal>
            </goals>
            <configuration>
              <outputDirectory>C:\Projects\Workspace-Eclipse-Junit\junit-5-basics-course\target\site</outputDirectory>
              <reportPlugins>
                <reportPlugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-project-info-reports-plugin</artifactId>
                </reportPlugin>
              </reportPlugins>
            </configuration>
          </execution>
          <execution>
            <id>default-deploy</id>
            <phase>site-deploy</phase>
            <goals>
              <goal>deploy</goal>
            </goals>
            <configuration>
              <outputDirectory>C:\Projects\Workspace-Eclipse-Junit\junit-5-basics-course\target\site</outputDirectory>
              <reportPlugins>
                <reportPlugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-project-info-reports-plugin</artifactId>
                </reportPlugin>
              </reportPlugins>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <outputDirectory>C:\Projects\Workspace-Eclipse-Junit\junit-5-basics-course\target\site</outputDirectory>
          <reportPlugins>
            <reportPlugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-project-info-reports-plugin</artifactId>
            </reportPlugin>
          </reportPlugins>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <reporting>
    <outputDirectory>C:\Projects\Workspace-Eclipse-Junit\junit-5-basics-course\target\site</outputDirectory>
  </reporting>
</project>

gdx19jrr

gdx19jrr3#

也供您参考安迪,尽管事实上,所有的测试都通过了

I still get in the maven task

相关问题