【问题标题】:How to make the Netty example works如何使 Netty 示例有效
【发布时间】:2016-02-04 06:53:29
【问题描述】:

我试图下载Netty Source Code 并运行包含的示例。

我安装的jdk版本是1.8.0_65

我尝试使用 maven(mvn eclipse:eclipse) 将示例(在示例文件夹 ...\netty-4.1\example 中)转换为 eclipse 项目。

但是得到下面所说的构建错误。

[INFO]
[INFO] >>> maven-eclipse-plugin:2.10:eclipse (default-cli) > generate-resources @ netty-example >>>
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.558 s
[INFO] Finished at: 2016-02-04T13:40:13+08:00
[INFO] Final Memory: 11M/28M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project netty-example: Could not resolve dependencies for project io.netty:netty-example:jar:4.1.0.CR2-SNAPSHOT: Failure to fi
nd io.netty:netty-tcnative:jar:windows-x86_32:1.1.33.Fork11 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be r
eattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project netty-example: Could not resolve dependencies for project io.netty:net
ty-example:jar:4.1.0.CR2-SNAPSHOT: Failure to find io.netty:netty-tcnative:jar:windows-x86_32:1.1.33.Fork11 in https://repo.maven.apache.org/maven2 was cached i
n the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
        at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:221)
        at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectDependencies(LifecycleDependencyResolver.java:127)
        at org.apache.maven.lifecycle.internal.MojoExecutor.ensureDependenciesAreResolved(MojoExecutor.java:245)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:199)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.MojoExecutor.executeForkedExecutions(MojoExecutor.java:352)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:197)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.project.DependencyResolutionException: Could not resolve dependencies for project io.netty:netty-example:jar:4.1.0.CR2-SNAPSHOT: Fai
lure to find io.netty:netty-tcnative:jar:windows-x86_32:1.1.33.Fork11 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution wil
l not be reattempted until the update interval of central has elapsed or updates are forced
        at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:211)
        at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:195)
        ... 27 more
Caused by: org.eclipse.aether.resolution.DependencyResolutionException: Failure to find io.netty:netty-tcnative:jar:windows-x86_32:1.1.33.Fork11 in https://repo
.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are
forced
        at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:384)
        at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:205)
        ... 28 more
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Failure to find io.netty:netty-tcnative:jar:windows-x86_32:1.1.33.Fork11 in https://repo.m
aven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are fo
rced
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:444)
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:246)
        at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:367)
        ... 29 more
Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Failure to find io.netty:netty-tcnative:jar:windows-x86_32:1.1.33.Fork11 in https://repo.maven
.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced

        at org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.newException(DefaultUpdateCheckManager.java:231)
        at org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.checkArtifact(DefaultUpdateCheckManager.java:206)
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.gatherDownloads(DefaultArtifactResolver.java:585)
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:503)
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:421)
        ... 31 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

我按照消息中提到的线索进行操作。我找到了链接到http://netty.io/wiki/forked-tomcat-native.html#wiki-h3-6this solution

我认为这可能不是我的目的。(我只想运行示例)。

所以我想知道要下载任何 Netty 开发库以开始 Netty 应用程序开发。或者任何 Pom.xml 共享链接都可以很容易地包含在示例项目中?谢谢。

【问题讨论】:

  • 您尝试过Force maven update 中的说明吗?它有助于解决was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced 问题。
  • 是的。我已经尝试过mvn clean install -U。错误仍然存​​在。
  • 我对它试图下载“io.netty:netty-tcnative:jar:windows-x86_32:1.1.33.Fork11”的事实感到困惑。你的设置有什么奇怪的东西,比如 32 位 maven 或类似的东西吗??
  • 我认为不是,因为 maven 确实适用于我计算机中的其他项目。所以maven设置没问题。对吗?
  • 哦。找到了 。 mvn -version 返回OS name: "windows 7", version: "6.1", arch: "x86", family: "dos"。这是否意味着我的计算机中的 32 位 maven?谢谢

标签: java eclipse maven netty


【解决方案1】:

这个答案是根据 Netty 项目上的bug report 做出的。

要构建 Netty 项目,您应该使用 64 位操作系统和 64 位 JVM。这是因为 Netty 项目使用的依赖项中有 1 个只支持 64 位。

根据mvn -version 的输出,您在32 位JVM 上运行。您应该可以从official java website 下载 64 位 JVM。

升级到 64 位 JVM 还具有以下优势:

  • 您可以运行超过 2 GB 内存的程序
  • 使用 longdouble 的计算会更快,因为 java 可以使用本机处理器

有关差异,请参阅:Benefits of 64bit java platform

你不需要自己编译示例,你也可以在 maven Central 上找到它们,按版本排序:http://central.maven.org/maven2/io/netty/netty-example/

【讨论】:

    【解决方案2】:

    看日志,好像没找到tcnative jar

    找不到 io.netty:netty-tcnative:jar:windows-x86_32:1.1.33.Fork11 在 https://repo.maven.apache.org/maven2 被缓存在本地 存储库,

    您可以尝试使用 maven 从命令行下载这个 tcnative jar,如下所示:

    mvn org.apache.maven.plugins:maven-dependency-plugin:get -DrepoUrl=http://central.maven.org/maven2/  -DgroupId=io.netty -DartifactId=netty-tcnative -Dversion=1.1.33.Fork11
    

    【讨论】:

    • 它不起作用。我这边可以访问网址http://central.maven.org/maven2/。顺便说一句,为什么我在您提到的网址中找不到“netty-tcnative”或tcnative?谢谢。
    • @Joe.wang 我的错。我发布了-Dversion: 而不是-Dversion=。你现在可以试试。我已经更新了命令。您还可以在http://central.maven.org/maven2/io/netty/netty-tcnative/ 找到 tcnative poms 和 jars
    • 真的有效!我也想知道提供的错误网址repo.maven.apache.org/maven2 在哪里?在我的 Maven 设置或 Netty 源项目中?谢谢。
    • 我不能说这是错误的 URL。但它是在你的 maven 安装的超级 POM 中配置的。它可以在 maven/lib 文件夹下的maven-model-builder-3.3.9.jar 中的org/apache/maven/model/pom-4.0.0.xml 文件中找到
    • :) 知道了。所以我想我最好在我的 pom.xml 中添加更多的存储库 url。对吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-06-23
    • 1970-01-01
    • 2023-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多