-1
I created a Javaee project directly in Intellij and added the Javaee 8 dependencies via Maven. The structure of the project is in this link.
web xml.:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
</web-app>
Beans.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
bean-discovery-mode="all">
</beans>
Jerseyconfig:
@ApplicationPath("resources")
public class JerseyConfig extends Application {
// @Override
// public Set<Class<?>> getClasses()
// {
// Set<Class<?>> yourResources = new HashSet<Class<?>>();
// yourResources.add(MySimpleRest.class);
// return yourResources;
// }
}
Mysimplerest :
@Path("/info")
public class MySimpleRest {
@GET
public String get(){
return "Hello Word";
}
}
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>JavaEE</groupId>
<artifactId>JavaEE</artifactId>
<version>1.0-SNAPSHOT</version>
<!--<packaging>war</packaging>-->
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>8.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
I’m trying to access the url http://localhost:9090/resources/info
and give me 404.
What am I doing wrong?
Which way to import the Resourceconfig? For me, it is not shown to import.
– Cristiano Bombazar
import org.glassfish.jersey.server.ResourceConfig
, I checked here and you don’t have the jersey dependencies I’ll add this to my answer.– Lucas Duete
I added the dependencies and it still doesn’t work. I tried with "Packages" and Register. I put a debug in the Jerseyconfig constructor, however, it did not pass there. I need to declare something in web.xml?
– Cristiano Bombazar
the method
MyApplication
in Jerseyconfig is the method builder, I misnamed so it should bepublic JerseyConfig() { }
– Lucas Duete
Yes, I’m on. I changed it to the right one, but it still doesn’t work...
– Cristiano Bombazar
is sure that the url
http://localhost:9090/resources/info
is correct? the application server did not put a path with the application name? something like:http://localhost:9090/myApplication/resources/info
– Lucas Duete
Let’s go continue this discussion in chat.
– Lucas Duete