Configure Eclipse to work with Java EE

First of all, I am new to EE and especially to Eclipse (I am working on Eclipse for the second time in my life :)).

Then I opened the Eclipse project, which was created by someone else. It uses Java EE (some EJBs, Persistence APIs ...). This project cannot be started, there are compilation errors - I cannot get it to use the EE libraries - it looks like this:

alt text

No annotations are known, and there is no quick fix. The project also contains Maven dependencies (I managed to install the Maven plugin for Eclipse), and all classes from the dependencies show warnings in the code. Like this:

alt text

How to configure Eclipse to work with this EE project so that it can be compiled and run? Thanks for answers.

EDIT: I am using Eclipse 2.0.0.2 and I have to use it - its version of Eclipse Rational Team Concept and version higher than 2.0.0.2 are not compatible with the RTC server.

+4
source share
2 answers

By the time, you should include the Java EE API in the build path of the project. The Java EE API is essentially an application server, such as, for example, Oracle Glassfish.

In Eclipse, open the Servers view in the lower right box. If not, then you need to add it. Right-click and select Create. The wizard must speak for himself. If there is no option for Sun or Oracle Glassfish, you need to install the Eclipse plugin separately. In newer versions of Eclipse, you can do this by clicking on β€œDownload additional server adapters” at the top of the wizard, and then selecting one of the Oracle Glassfish Server tools. If in an older version of Eclipse you need to install it manually according to the instructions on the home page .

After the server is integrated into Eclipse (or actually already exists), you should right-click on the dynamic web project and go to the Target battery life section. Select the integrated server there. Rebuild if necessary.

+5
source

Some suggestions

  • make your Java level at level 5 or higher Window > Preferences > Java Compiler set the drop-down menu to something higher or equal to 1.5.
  • Clean the project by clicking Project > clean...
  • Right click the top project folder and Maven > update project configuration and Maven > update project configuration

To build

Right-click in the top project folder and run as.. > maven clean , and then run ".. like"> maven install`

Hope this helps

By the way, why not use a newer version, such as Eclipse 3.6.x or later?

0
source

Source: https://habr.com/ru/post/1336697/


All Articles