How do I upgrade an existing NetBeans Java EE 6 Web project to Java EE 7?

可紊 提交于 2019-12-06 11:15:43

问题


The project uses JavaServer Faces and JPA. NetBeans 7.3.1 IDE does not allow to change the Java EE version.

I already found this question:

How do I upgrade an existing enterprise project from Java EE5 to Java EE 6 in Netbeans (6.9)

tries to apply the changes as described. I have updated project.properties.

endorsed.classpath=\
    ${libs.javaee-endorsed-api-7.0.classpath}

...

j2ee.platform=1.7-web

...

javac.source=1.7
javac.target=1.7

回答1:


I just had to do the same thing, I had an Java EE 6 Application and wanted to go to Java EE 7.

I just made a new project in Netbeans, then I selected Java Web in 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.




回答2:


NetBeans won't automatically update the project files when you update the version in project.properties. You'll have to do it by hand.

  • 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.

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.




回答3:


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:

<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>



回答4:


  1. Go to NetBeans Project Directory
  2. Go to nbproject
  3. Open project.properties
  4. Find j2ee.platform
  5. Change FROM j2ee.platform=1.7-web TO j2ee.platform=1.6-web

  6. Also change j2ee.server.home in nbproject\private\private.properties to directory path of J2EE matching Server



来源:https://stackoverflow.com/questions/17586372/how-do-i-upgrade-an-existing-netbeans-java-ee-6-web-project-to-java-ee-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!