我正在使用以下方法制作API: Java 11 Java EE 8 Maven, Wildfly 17.0.1 Final, IntelliJ
现在,我的API使用了简单的“ HOLA MUNDO”(我的代码是西班牙文),但是有两种情况使我不满意,并且我不希望它们出现
我的项目名称为“ psohc”,并且可以正常编译,并且我已经配置了IntelliJ,以便在展开战争后转到http://localhost:8080/psohc/,但显示以下消息:
最后的问题 这是我的IntelliJ配置,是的,凭据很好
此外,如果我转到基本应用程序类路径,则会显示以下Resteasy错误(带有或不带有helloWorld路径,此后的代码):
这就是我所拥有的:
<?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>com.project.psohc</groupId>
<artifactId>psohc</artifactId>
<version>1.0</version>
<modules>
<module>servicios</module>
</modules>
<packaging>pom</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.jupiter.version>5.5.0</junit.jupiter.version>
</properties>
<name>Project psohc</name>
<dependencies>
<!-- https://mvnrepository.com/artifact/javax/javaee-api -->
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>8.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.12.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.12.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.5.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>psohc</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<encoding>UTF-8</encoding>
<release>11</release>
</configuration>
</plugin>
</plugins>
</build>
</project>
<?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">
<parent>
<artifactId>servicios</artifactId>
<groupId>com.ucab.psohc</groupId>
<version>1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>implementacion</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<name>psohc.servicios.implementacion</name>
<dependencies>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-jaxrs -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>3.6.3.SP1</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-multipart-provider -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-multipart-provider</artifactId>
<version>4.1.1.Final</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jboss.spec.javax.ws.rs/jboss-jaxrs-api_2.1_spec -->
<dependency>
<groupId>org.jboss.spec.javax.ws.rs</groupId>
<artifactId>jboss-jaxrs-api_2.1_spec</artifactId>
<version>1.0.3.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-client -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<version>3.0.6.Final</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.thetransactioncompany/cors-filter -->
<dependency>
<groupId>com.thetransactioncompany</groupId>
<artifactId>cors-filter</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>com.ucab.psohc</groupId>
<artifactId>comandos</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<warName>psohc</warName>
</configuration>
</plugin>
</plugins>
</build>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>psohc</display-name>
<filter>
<filter-name>CORS</filter-name>
<filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class>
<init-param>
<param-name>cors.supportedMethods</param-name>
<param-value>GET, POST</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CORS</filter-name>
<url-pattern>*</url-pattern>
</filter-mapping>
</web-app>
我的应用程序基类:
@ApplicationPath("/api")
public class ServicioAplicacionBase extends Application {
@Override
public Set<Class<?>> getClasses() {
final HashSet<Class<?>> response = new HashSet<>();
response.add(ServicioArchivo.class);
return response;
}
@GET
@Path( "/helloWorld" )
@Produces(MediaType.APPLICATION_JSON)
public String helloWorld()
{
return "HOLA MUNDO";
}
}
我的服务类别:
@Path( "/archivo" )
@Produces( MediaType.APPLICATION_JSON )
public class ServicioArchivo extends ServicioAplicacionBase {
@GET
@Path( "/helloWorld" )
@Produces(MediaType.APPLICATION_JSON)
public String helloWorld()
{
return "HOLA MUNDO";
}
}
现在,正如我提到的,如果我插入以下路径http://localhost:8080/psohc/api/archivo/helloWorld,它确实可以工作:
所以我的问题是:
为什么我会收到“禁止”消息?有什么办法显示其他东西或重定向到其他地方?
为什么“ HOLA MUNDO”消息确实出现在http://localhost:8080/psohc/api/archivo/helloWorld中;但是在http://localhost:8080/psohc/api/helloWorld和http://localhost:8080/psohc/api中出现了RESTEASY路径错误吗?
PS:我对Resteasy没有特殊的配置