Java 在 Eclipse 中添加 org.glassfish.jersey.archetypes

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31721013/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 11:30:31  来源:igfitidea点击:

Adding org.glassfish.jersey.archetypes in eclipse

javaeclipserestmavenglassfish

提问by user1326301

I am trying to create a maven project in eclipse. I am trying create a archetype but getting the below error.

我正在尝试在 Eclipse 中创建一个 Maven 项目。我正在尝试创建一个原型,但出现以下错误。

Can't resolve Archetype org.glassfish.jersey.archetypes:jersey-quickstart-webapp:2.16
org.eclipse.core.runtime.CoreException: Could not resolve artifact org.glassfish.jersey.archetypes:jersey-quickstart-webapp:pom:2.16

无法解析 Archetype org.glassfish.jersey.archetypes:jersey-quickstart-webapp:2.16
org.eclipse.core.runtime.CoreException: 无法解析工件 org.glassfish.jersey.archetypes:jersey-quickstart-webapp:pom: 2.16

回答by sreejith v s

You can solve this issue by adding a new Maven Archetype.

您可以通过添加新的 Maven Archetype 来解决此问题。

  1. Open Window > Preferences
  2. Open Maven > Archetypes
  3. Click Add Remote Catalogand add the following:
    • Catalog File: https://repo.maven.apache.org/maven2/archetype-catalog.xml
    • Description: maven catalog
  4. Restart eclipse
  1. 打开 Window > Preferences
  2. 打开 Maven > Archetypes
  3. 单击Add Remote Catalog并添加以下内容:
    • 目录文件https://repo.maven.apache.org/maven2/archetype-catalog.xml
    • 说明maven catalog
  4. 重启日食

Try creating a maven project again. It will work :).

再次尝试创建一个 Maven 项目。它会起作用:)。

{search filter:jersey-quickstart-webapp}

You will have the latest version.

您将拥有最新版本。

回答by Deepak Acharya

One point I want to add, If you are getting following error while installing the archetype showed in image 1

我想补充一点,如果您在安装图 1 中显示的原型时遇到以下错误

Can't resolve Archetype org.glassfish.jersey.archetypes:jersey-quickstart-webapp:2.21 org.eclipse.core.runtime.CoreException: Could not resolve artifact org.glassfish.jersey.archetypes:jersey-quickstart-webapp:pom:2.21

无法解析 Archetype org.glassfish.jersey.archetypes:jersey-quickstart-webapp:2.21 org.eclipse.core.runtime.CoreException: 无法解析工件 org.glassfish.jersey.archetypes:jersey-quickstart-webapp:pom: 2.21

Image 1: enter image description here

图 1: 在此处输入图片说明

Then before procedding with the solution specified in this page, try to complete these stepsin eclipse.

然后在继续使用本页中指定的解决方案之前,尝试在 eclipse 中完成这些步骤

回答by Nitesh Goyal

You can solve this issue by adding a new Maven Archetype locally. By locally, I mean-

您可以通过在本地添加新的 Maven Archetype 来解决此问题。在本地,我的意思是-

  1. Go to this URLand download the XML file at your local file system.
  2. Open Window > Preferences
  3. Open Maven > Archetypes
  4. Click Add Local Catalog > Browse to the location of your archetype-catalog.xmlfile
  5. Add Descritpion
    1. OK
  1. 转到此URL并在本地文件系统中下载 XML 文件。
  2. 打开 Window > Preferences
  3. 打开 Maven > Archetypes
  4. 单击添加本地目录 > 浏览到archetype-catalog.xml文件所在的位置
  5. 添加描述
    1. 好的

Hope this will help you.

希望这会帮助你。

回答by Noothan y v

There could be issue with internet connecting to your eclipse marketplace. below changes would solve your issue

互联网连接到您的日食市场可能存在问题。以下更改将解决您的问题

Open Window > Preferences>Open Maven > Archetypes Click on Add Remote Catalog Catalog File: http://repo1.maven.org/maven2/archetype-catalog.xmlDone Create Project, you should be able to see archtypes of jersey

Open Window > Preferences > Open Maven > Archetypes 点击Add Remote Catalog Catalog File:http: //repo1.maven.org/maven2/archetype-catalog.xml Done Create Project,你应该可以看到jersey的archtypes

回答by ram kumar

Try to change the version 2.21insted of 2.16:

尝试更改2.16 的2.21insted版本:

org.glassfish.jersey.archetypes jersey-quickstart-webapp 2.21

回答by Nupur

Thanks @sreejith v s . The above mentioned method worked completely fine .I'll repeat the same steps here:-

谢谢@sreejith vs . 上面提到的方法工作得很好。我会在这里重复相同的步骤:-

  1. Open Window > Preferences
  2. Open Maven > Archetypes
  3. Click Add Remote Catalog and add the following:

    3.1 Catalog File: http://repo1.maven.org/maven2/archetype-catalog.xml

    3.2 Description: maven catalog

  4. Restart eclipse

  1. 打开窗口 > 首选项
  2. 打开 Maven > 原型
  3. 单击添加远程目录并添加以下内容:

    3.1 目录文件:http: //repo1.maven.org/maven2/archetype-catalog.xml

    3.2 说明:maven目录

  4. 重启日食

While creating maven project your window might take time to load all the Archetype but it does load all of them because here we have added the archetype-catalog.xml as remote catalog file.

在创建 maven 项目时,您的窗口可能需要时间来加载所有原型,但它确实加载了所有原型,因为这里我们添加了 archetype-catalog.xml 作为远程目录文件。

回答by crazysj

Steps

脚步

  1. Open Eclipse
  2. Choose New > Project > Maven Project
  3. Choose Add Archetypeand enter the following details:
    • Archetype Group ID: org.glassfish.jersey.archetypes
    • Archetype Artifact ID: jersey-quickstart-webapp
    • Archetype Version: 2.16[enter the latest version that is available]
  4. Choose the newly entered archetype from the Archetype selection screen
  5. Enter your project details - Group ID, Artifact IDand Version.
  1. 打开日食
  2. 选择 New > Project > Maven Project
  3. 选择Add Archetype并输入以下详细信息:
    • 原型组 ID: org.glassfish.jersey.archetypes
    • 原型工件 ID: jersey-quickstart-webapp
    • 原型版本:2.16[输入可用的最新版本]
  4. 从原型选择屏幕中选择新输入的原型
  5. 输入您的项目详细信息 - Group IDArtifact IDVersion

More Information: https://javabrains.io/courses/javaee_jaxrs/lessons/Setting-Up

更多信息:https: //javabrains.io/courses/javaee_jaxrs/lessons/Setting-Up

回答by Abhishek

Please ensure that you have correct entries into your settings.xml which is located at .m2/settings.xmlor {maven_home}/conf/settings.xml

请确保您在位于.m2/settings.xml{maven_home}/conf/settings.xml 的settings.xml 中有正确的条目

<settings>
  <proxies>
   <proxy>
      <active>true</active>
      <protocol>http</protocol>
      <host>YOUR.PROXY.IP.OR.NAME</host>
      <port>YOUR PROXY PORT</port>
      <username>YOUR PROXY USERNAME (OR EMPTY IF NOT REQUIRED)</username>
      <password>YOUR PROXY PASSWORD (OR EMPTY IF NOT REQUIRED)</password>
      <nonProxyHosts>YOUR PROXY EXCLUSION HOST LIST (OR EMPTY)</nonProxyHosts>
    </proxy>
  </proxies>
</settings>

If you are building from your eclipse ensure that Windows>Preference>{Search Maven}>{Select "User Settings"}>{Update settings.xml location}

如果您从 Eclipse 构建,请确保Windows>Preference>{Search Maven}>{Select "User Settings"}>{Update settings.xml location}

If you are building from command line you may directly use:

如果您是从命令行构建,则可以直接使用:

mvn archetype:generate -DarchetypeGroupId=org.glassfish.jersey.archetypes -DarchetypeArticfactId=jersey-quickstart.webapp -DarchetypeVersion=2.28 -DinteractiveMode=false

回答by Ashwin

For me it worked with https instead of http in the below URL http://repo1.maven.org/maven2/archetype-catalog.xml

对我来说,它在下面的 URL http://repo1.maven.org/maven2/archetype-catalog.xml 中使用 https 而不是 http

Can use the 'Verify' option in the Maven > Archetypes to check which one is working

可以使用 Maven > Archetypes 中的“验证”选项来检查哪个正在工作