首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法解决项目org.openjdk.jmh:jmh:jar:1.21的依赖关系

无法解决项目org.openjdk.jmh:jmh:jar:1.21的依赖关系
EN

Stack Overflow用户
提问于 2019-04-10 07:33:11
回答 2查看 2.8K关注 0票数 3

想要开始做方法的基准测试,从现在开始写,从很长一段时间就有了动力,最后决定从昨天开始做。但我对我的设置过程很感兴趣。

  • 我已经正确安装了JMH插件。
  • 所有进口产品都正常工作。
  • 即使是我的POM也没有显示错误。

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

未能执行项目TestOptional:无法解决项目Vishwaratna的依赖关系:TestOptional:jar:1.0-快照:下列工件无法解析d: jmh-core:jmh:1.21,org.openjdk.jmh:jmh-generator-annprocess:jar:1.21:找不到art_all中的工件org.openjdk.jmh:jmh-core:jar:1.21 (http://maven/artifactory/li bs-快照)

我想我必须强制更新repos,所以我运行了mvn -U clean install,再次没有运气。

做了大量的搜索,检查了N个SO线程,但仍然找不出我哪里出错了。

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

没有匹配的基准。小姐-拼写为regexp? 使用额外的详细模式来调试模式匹配. 进程已完成,退出代码为%1

我感到困惑的是,当maven无法从中央代表中找到那些JMH库时,为什么我的带有所有注释的代码没有显示红色编译错误呢?如果lib导入正确,那么为什么当我从终端运行mvn clean install时不能下载xx的错误呢?

经过两个小时的挣扎,我想放弃POM.xml,尝试手动添加jar,下载JMH注释jar和JMH核心jar并手动配置路径。猜猜还有什么不走运的。

如果你想知道我在编码什么:

代码语言:javascript
复制
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();
    }
}

My POM.XML

代码语言:javascript
复制
<?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>

我想要一个详细的解决方案,这将有助于那些在未来偶然发现这条线索的人。

参考文献和尝试:

  • HelloWorld.java
  • http://mail.openjdk.java.net/pipermail/jmh-dev/2013-July/000123.html
  • HelloWorld.java

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

输出

代码语言:javascript
复制
[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] ------------------------------------------------------------------------

编辑:

通过命令mvn -U clean install,我不得不更新repos,并获得了这些下载。

拿起_JAVA_OPTIONS:-Djava.net.preferIPv4Stack=true信息扫描项目.在构建Vishwaratna的有效模型时遇到了一些问题:TestOptional:jar:1.0-快照警告‘org.apache.maven.plugins:maven-compiler-plugin .(groupId:artifactId)’必须是唯一的,但是发现插件org.apache.maven.plugins:maven-compiler-plugin @第86行的重复声明,org.apache.maven.plugins:maven-compiler-plugin的第21列警告'build.plugins.plugin.version‘缺失了。@第86行,第21栏,警告org.codehaus.mojo:exec plugin的“build.plugins.plugin.version”缺失。@第63行,第21栏警告强烈建议修复这些问题,因为它们威胁到您的构建的稳定性。由于这个原因,未来的Maven版本可能不再支持构建这种格式错误的项目。警告信息信息大楼TestOptional 1.0-快照信息没有可用的依赖信息下载: org.openjdk.jmh:jmh-generator-annprocess:jar:1.21的http://maven/artifactory/libs-snapshot/org/openjdk/jmh/jmh-generator-annprocess/1.21/jmh-generator-annprocess-1.21.pom下载:警告POM的http://maven/artifactory/libs-snapshot/org/openjdk/jmh/jmh-generator-annprocess/1.21/jmh-generator-annprocess-1.21.pom丢失,没有依赖信息下载:下载:http://maven/artifactory/libs-snapshot/org/openjdk/jmh/jmh-core/1.21/jmh-core-1.21.jar下载:http://maven/artifactory/libs-snapshot/org/openjdk/jmh/jmh-generator-annprocess/1.21/jmh-generator-annprocess-1.21.jar下载:http://maven/artifactory/libs-snapshot/org/openjdk/jmh/jmh-generator-annprocess/1.21/jmh-generator-annprocess-1.21.jar下载:http://maven/artifactory/libs-snapshot/org/openjdk/jmh/jmh-core/1.21/jmh-core-1.21.jar信息生成失败信息信息总时间: 17.150 s信息完成于: 2019-04-10T14:57:16+05:30 INFO最终内存:7m/125 m INFO?错误未能在项目TestOptional:无法解决项目TestOptional:TestOptional:jar:1.0的依赖项上执行目标:以下工件无法解析d: org.openjdk.jmh:jmh-core:jar:1.21,org.openjdk.jmh:jmh-generator-annprocess:jar:1.21:找不到art_all中的工件org.openjdk.jmh:jmh-core:jar:1.21 (http://maven/artifactory/li bs-快照)

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

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

Msg:

代码语言:javascript
复制
{
  "errors" : [ {
    "status" : 404,
    "message" : "Could not find resource"
  } ]
}

设置XML

代码语言:javascript
复制
<?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>

设置Artifactory xml:

代码语言:javascript
复制
<?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>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-04-10 07:59:35

我已经成功地运行了你的例子。我唯一需要改变的就是把你的Testing.java放到任何包中,例如package t;

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

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

票数 1
EN

Stack Overflow用户

发布于 2021-09-06 08:05:39

对我来说,唯一的解决方案是访问${user.home}/.m2/的本地maven存储库并删除jmh包。

代码语言:javascript
复制
rm -Rf ${user.home}/.m2/repository/org/openjdk/jmh*

然后,IntelliJ可以再次下载这个包,当我做cleaninstall时。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55607083

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档