当前位置: 首页 > 知识库问答 >
问题:

无法解析项目org.openjdk.jmh:jmh-core:jar:1.21的依赖项

陶星辰
2023-03-14

我想从现在开始做我将写的方法的基准,从很长一段时间就有了动力,最后决定从昨天开始做。但我的设置过程让我大吃一惊。

  • 我已正确安装了JMH插件。
  • 所有导入操作正常。
  • 即使是我的POM也没有显示错误。

但是当我运行命令mvn clean install时,我会得到以下错误:

我做了大量的搜索,通过了N个SO线程,但仍然不能弄清楚我哪里出了问题。

当我刚刚运行我的testing.java类时,我得到以下消息:

没有匹配的基准。拼写错误的正则表达式?

使用额外的详细模式来调试模式匹配。

进程已完成,退出代码为%1

import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;

public class Testing {
    @Benchmark
    @BenchmarkMode({ Mode.AverageTime})
    public void wellHelloThere() {
        // this method was intentionally left blank.
    }
    public static void main(String[] args) throws RunnerException {
        Options opt = new OptionsBuilder()
            .include(Testing.class.getSimpleName())
            .forks(1)
            .build();

        new Runner(opt).run();
    }
}
<?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>Vishwaratna</groupId>
    <artifactId>TestOptional</artifactId>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <jmh.version>1.21</jmh.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.openjdk.jmh</groupId>
            <artifactId>jmh-core</artifactId>
            <version>${jmh.version}</version>
        </dependency>
        <dependency>
            <groupId>org.openjdk.jmh</groupId>
            <artifactId>jmh-generator-annprocess</artifactId>
            <version>${jmh.version}</version>
        </dependency>
    </dependencies>
    <repositories>

            <repository>
                <id>central-repo</id>
                <name>Central Repository</name>
                <url>http://repo1.maven.org/maven2</url>
                <releases>
                    <enabled>false</enabled>
                    <updatePolicy>always</updatePolicy>
                    <checksumPolicy>warn</checksumPolicy>
                </releases>
            </repository>


    </repositories>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>

                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.openjdk.jmh</groupId>
                            <artifactId>jmh-generator-annprocess</artifactId>
                            <version>1.21</version>
                        </path>
                    </annotationProcessorPaths>

                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>run-benchmarks</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <classpathScope>test</classpathScope>
                            <executable>java</executable>
                            <arguments>
                                <argument>-classpath</argument>
                                <classpath />
                                <argument>org.openjdk.jmh.Main</argument>
                                <argument>.*</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>

                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>


</project>

参考和试用:

  • http://hg.openjdk.java.net/code-tools/jmh/file/004bc63876c5/jmh-samples/src/main/java/org/openjdk/jmh/samples/jmhsample_01_helloworld.java
  • http://mail.openjdk.java.net/pipermail/jmh-dev/2013-july/000123.html
  • https://hg.openjdk.java.net/code-tools/jmh/file/5984e353dca7/jmh-samples/src/main/java.org/openjdk/jmh/samples/jmh/samples/jmhsample_01_helloworld.java

运行了以下命令:mvn versions:display-dependency-updates

输出:

[INFO]
[INFO] All plugins with a version specified are using the latest versions.
[INFO]
[WARNING] The following plugins do not have their version specified:
[WARNING]   maven-clean-plugin .......................... (from super-pom) 2.5
[WARNING]   maven-compiler-plugin ..................... (from super-pom) 2.0.2
[WARNING]   maven-deploy-plugin ......................... (from super-pom) 2.3
[WARNING]   maven-install-plugin ........................ (from super-pom) 2.4
[WARNING]   maven-jar-plugin ............................ (from super-pom) 2.4
[WARNING]   maven-resources-plugin ...................... (from super-pom) 2.6
[WARNING]   maven-site-plugin ........................... (from super-pom) 3.3
[WARNING]   maven-surefire-plugin .................... (from super-pom) 2.12.4
[WARNING]   org.codehaus.mojo:exec-maven-plugin ........................ 1.5.0
[INFO]
[WARNING] Project does not define minimum Maven version, default is: 2.0
[INFO] Plugins require minimum Maven version of: 3.0
[INFO] Note: the super-pom from Maven 3.2.5 defines some of the plugin
[INFO]       versions and may be influencing the plugins required minimum Maven
[INFO]       version.
[INFO]
[ERROR] Project does not define required minimum version of Maven.
[ERROR] Update the pom.xml to contain
[ERROR]     <prerequisites>
[ERROR]       <maven>3.0</maven>
[ERROR]     </prerequisites>
[INFO]
[INFO] Require Maven 2.0.6 to use the following plugin updates:
[INFO]   maven-clean-plugin .............................................. 2.5
[INFO]   maven-deploy-plugin ........................................... 2.8.1
[INFO]   maven-install-plugin .......................................... 2.5.1
[INFO]   maven-jar-plugin ................................................ 2.4
[INFO]   maven-resources-plugin .......................................... 2.6
[INFO]   maven-site-plugin ............................................. 2.0.1
[INFO]   org.codehaus.mojo:exec-maven-plugin ........................... 1.2.1
[INFO]
[INFO] Require Maven 2.0.9 to use the following plugin updates:
[INFO]   maven-compiler-plugin ........................................... 3.1
[INFO]   maven-surefire-plugin .......................................... 2.17
[INFO]
[INFO] Require Maven 2.2.0 to use the following plugin updates:
[INFO]   maven-site-plugin ............................................... 3.0
[INFO]
[INFO] Require Maven 2.2.1 to use the following plugin updates:
[INFO]   maven-clean-plugin ............................................ 2.6.1
[INFO]   maven-compiler-plugin ........................................... 3.3
[INFO]   maven-deploy-plugin ........................................... 2.8.2
[INFO]   maven-install-plugin .......................................... 2.5.2
[INFO]   maven-jar-plugin ................................................ 2.6
[INFO]   maven-resources-plugin .......................................... 2.7
[INFO]   maven-site-plugin ............................................... 3.4
[INFO]   maven-surefire-plugin ........................................ 2.19.1
[INFO]   org.codehaus.mojo:exec-maven-plugin ........................... 1.4.0
[INFO]
[INFO] Require Maven 3.0 to use the following plugin updates:
[INFO]   maven-compiler-plugin ................................. 3.8.0-jboss-2
[INFO]   maven-resources-plugin ........................................ 3.0.2
[INFO]   maven-site-plugin ............................................... 3.6
[INFO]   org.codehaus.mojo:exec-maven-plugin ........................... 1.5.0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11:33 min
[INFO] Finished at: 2019-04-10T14:45:21+05:30
[INFO] Final Memory: 15M/261M
[INFO] ------------------------------------------------------------------------

编辑:

这表明我没有任何代理问题,现在当我在浏览器中套用任何JMH链接时,我得到一个json响应,例如:

链接:http://maven/artifactory/libs-snapshot/org/openjdk/jmh/jmh-core/1.21/jmh-core-1.21.jar

味精:

{
  "errors" : [ {
    "status" : 404,
    "message" : "Could not find resource"
  } ]
}
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

  <localRepository>C:\GBO_ROOT\Repo</localRepository> 

    <servers>
        <server>
            <id>TomcatServer</id>
            <username>admin</username>
            <password>password</password>
        </server>
    </servers>
    <mirrors>   
     <mirror> 
      <id>art_central</id> 
      <name>Artifactory Mirror of Central</name> 
      <url>http://maven/artifactory/libs-snapshot</url> 
      <mirrorOf>central</mirrorOf> 
    </mirror> 
    <mirror> 
      <id>art_all</id> 
      <name>Artifactory Mirror of Central</name> 
      <url>http://maven/artifactory/libs-snapshot</url> 
      <mirrorOf>*</mirrorOf> 
    </mirror> 
  </mirrors>
  <profiles>
    <profile>  
      <id>artifactory</id>  
      <repositories>  
        <repository>  
          <snapshots />  
          <id>snapshots</id>  
          <name>libs-snapshot</name>  
          <url>http://maven/artifactory/libs-snapshot</url>   
        </repository>  
      </repositories>  
      <pluginRepositories>  
        <pluginRepository>  
          <snapshots />  
          <id>snapshots</id>  
          <name>plugins-snapshot</name>  
          <url>http://maven/artifactory/plugins-snapshot</url>   
        </pluginRepository>  
      </pluginRepositories>  
    </profile>  
  </profiles>

  <activeProfiles>  
    <activeProfile>artifactory</activeProfile>  
  </activeProfiles>
</settings>
<?xml version="1.0" encoding="UTF-8"?>

<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"
          xmlns="http://maven.apache.org/SETTINGS/1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <localRepository>C:/EMA_ROOT/snapshotviews/repo</localRepository>     
  <mirrors>   
     <mirror> 
      <id>art_central</id> 
      <name>Artifactory Mirror of Central</name> 
      <url>http://maven/artifactory/libs-snapshot</url> 
      <mirrorOf>central</mirrorOf> 
    </mirror> 
    <mirror> 
      <id>art_all</id> 
      <name>Artifactory Mirror of Central</name> 
      <url>http://maven/artifactory/libs-snapshot</url> 
      <mirrorOf>*</mirrorOf> 
    </mirror> 
  </mirrors>
  <profiles>
    <profile>  
      <id>artifactory</id>  
      <repositories>  
        <repository>  
          <snapshots />  
          <id>snapshots</id>  
          <name>libs-snapshot</name>  
          <url>http://maven/artifactory/libs-snapshot</url>   
        </repository>  
      </repositories>  
      <pluginRepositories>  
        <pluginRepository>  
          <snapshots />  
          <id>snapshots</id>  
          <name>plugins-snapshot</name>  
          <url>http://maven/artifactory/plugins-snapshot</url>   
        </pluginRepository>  
      </pluginRepositories>  
    </profile>  
  </profiles>

  <activeProfiles>  
    <activeProfile>artifactory</activeProfile>  
  </activeProfiles>
</settings>

共有1个答案

汲利
2023-03-14

我已经成功地运行了你的例子。唯一需要更改的是将testing.java放入任何包中,例如包T;

如果您的回购有任何问题,请尝试在settings.xml文件中没有任何奇怪的设置。https://maven.apache.org/settings.html。可能有一些proxing集或类似的东西,它可能会改变项目的预期行为。

settings.xml中的URL更改为https://repo1.maven.org/maven2/

 类似资料:
  • 我希望有人面对同样的问题来解决依赖。下面提到的文件 xsi:schemalocation=“http://maven.apache.org/pom/4.0.0 http://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/x

  • 我对Android的Gradle构建有问题。我尝试了很多方法来解决这个问题,但没有什么不起作用。我需要帮助。 Gradle版本:4.4 Gradle插件:3.0.1 错误:无法解析app@serverDebug /compileClasspath的依赖关系:无法解析项目:vksdk_library。 错误:无法解析“”的依存关系:app@mockDebugAndroidTest/compileCl

  • 我是Android Studio的新手,面临以下错误。 错误:无法解析“:”的依赖项app@debug/compileClasspath“:无法解析项目:floatinglibrary。显示受影响模块的详细信息:应用 错误:无法解析“:app@debug/编译类路径”的依赖关系:无法解析项目:d时间筛选库。显示详细信息 受影响的模块:应用

  • 我想通过Jenkins用maven Build运行一个项目。 使用的存储库-Git从存储库中提取代码 使用的构建工具--Maven 我的jenkins控制台输出 请注意:-如果你看不到图像,只需使用Ctrl++缩放即可

  • 我试图在Heroku中部署maven web应用程序,它依赖于其他应用程序。当我试图部署应用程序时,却遇到了这个错误。我不知道在传递依赖项时出了什么问题。 错误日志-------- !错误:未能用Maven构建应用程序,我们很抱歉这个构建失败了!如果您在应用程序代码中找不到问题,请提交一张票证,以便我们提供帮助:https://help.heroku.com/!推送被拒绝,无法编译Java应用程序

  • 问题是gradle找不到依赖项的jar,但gradle找错了地方。Gradle一直在错误的目录(谷歌和Android支持libary的目录)中搜索文件.... 在以下位置搜索:文件:/d://programme/androis-sdks/extras/android/m2repository/org/springframework/android/spring-android-rest-templ