eclipse-ee4j / jakartaee-firstcup

First Cup of Jakarta EE Tutorial
https://eclipse-ee4j.github.io/jakartaee-firstcup
Eclipse Public License 2.0
13 stars 17 forks source link

Need more explanation about "import javax.ws.rs.*" there are more then one choice. #10

Open glassfishrobot opened 7 years ago

glassfishrobot commented 7 years ago

I'm using NetBeans 8.2 and Java EE 8. I'm followed the tutorial but at the "Creating the dukes-age Application Using the Maven Archetype" point there is a problem, this line give error:

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;

Because there are multiple match to the package javax.ws.rs through the "Search Dependency at Maven Repositories for javax.ws.rs" I get this:

so what I should choose? I think that the tutorial should explain this point.

I give to Oracle and all Users the right to post, access, discuss, use, publish, disseminate, and refine mine Submissions.

glassfishrobot commented 5 years ago
glassfishrobot commented 7 years ago

@deglans Commented After many research it's same to be javaee-api the most correct answer...

glassfishrobot commented 7 years ago

@deglans Commented Sorry, i have accidentally close the issue...

glassfishrobot commented 7 years ago

@bshannon Commented If you're building a Java EE application for deployment to a Java EE application server, then compiling against the javaee-api jar file is the right thing to do. Be sure to list it as a "provided" dependency since you don't want that jar file included in your application at runtime.

glassfishrobot commented 7 years ago

@deglans Commented Do you mean this (https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html):

provided This is much like compile, but indicates you expect the JDK or a container to provide the dependency at runtime. For example, when building a web application for the Java Enterprise Edition, you would set the dependency on the Servlet API and related Java EE APIs to scope provided because the web container provides those classes. This scope is only available on the compilation and test classpath, and is not transitive.

So the pom.xml become:

<dependency>
    <groupId>javax</groupId>
    <artifactId>javaee-api</artifactId>
    <version>8.0</version>
    <type>jar</type>
    <scope>provided</scope>
</dependency>

Is that right? I think this explanation should be included in the tutorial....

glassfishrobot commented 7 years ago

@bshannon Commented Yes.