如何将现有的 NetBeans Java EE 6 Web 项目升级到 Java EE 7?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17586372/
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
How do I upgrade an existing NetBeans Java EE 6 Web project to Java EE 7?
提问by mjn
The project uses JavaServer Faces and JPA. NetBeans 7.3.1 IDE does not allow to change the Java EE version.
该项目使用 JavaServer Faces 和 JPA。NetBeans 7.3.1 IDE 不允许更改 Java EE 版本。
I already found this question:
我已经找到了这个问题:
How do I upgrade an existing enterprise project from Java EE5 to Java EE 6 in Netbeans (6.9)
如何在 Netbeans (6.9) 中将现有企业项目从 Java EE5 升级到 Java EE 6
tries to apply the changes as described. I have updated project.properties.
尝试应用所描述的更改。我已经更新了 project.properties。
endorsed.classpath=\
${libs.javaee-endorsed-api-7.0.classpath}
...
...
j2ee.platform=1.7-web
...
...
javac.source=1.7
javac.target=1.7
回答by Ian Evans
NetBeans won't automatically update the project files when you update the version in project.properties
. You'll have to do it by hand.
当您更新project.properties
. 你必须手工完成。
- Update the deployment descriptors in your project to use the Java EE 7 namespaces and schemas.
- Update the code to use the new APIs and features.
- Add a Java EE 7 server instance to your Servers, like GlassFish 4.0, and set it as the target server in the Run tab in Project Properties.
- 更新项目中的部署描述符以使用Java EE 7 名称空间和模式。
- 更新代码以使用新的 API 和功能。
- 将 Java EE 7 服务器实例添加到您的服务器,例如 GlassFish 4.0,并在项目属性的运行选项卡中将其设置为目标服务器。
It's also worth noting that the Java EE version in NetBeans projects doesn't actually affect anything, in my experience. You can have the Java EE version set to 6 in your project, but if it uses EE 7 features and is deployed to a Java EE 7 server, it will run correctly.
还值得注意的是,根据我的经验,NetBeans 项目中的 Java EE 版本实际上没有任何影响。您可以将项目中的 Java EE 版本设置为 6,但如果它使用 EE 7 功能并部署到 Java EE 7 服务器,它将正确运行。
回答by Reitffunk
I just had to do the same thing, I had an Java EE 6 Application and wanted to go to Java EE 7.
我只需要做同样的事情,我有一个 Java EE 6 应用程序,并且想要转到 Java EE 7。
I just made a new project in Netbeans, then I selected Java Webin Categories and then Web Application with existing sources. Then Netbeans will present you a wizard, where you choose your EE6 project. After that you also can set an other Java EE Version.
我刚刚在 Netbeans 中创建了一个新项目,然后在 Categories 中选择了Java Web,然后在Web Application with existing sources 中选择了Java Web。然后 Netbeans 将向您展示一个向导,您可以在其中选择 EE6 项目。之后,您还可以设置其他 Java EE 版本。
回答by Martijn Burger
In Netbeans 8.1 I guess this changed. I needed to update the information in the nb-configuration.xml
For Java EE 7 it is:
在 Netbeans 8.1 中,我猜这改变了。我需要更新nb-configuration.xml
For Java EE 7 中的信息,它是:
<project-shared-configuration>
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
<org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>1.7</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>
</properties>
</project-shared-configuration>