简体   繁体   English

尝试使用 postman 调用 url 时找不到 404

[英]Getting a 404 not found when trying to call url with postman

I was working on my old project with maven, trying to implement a rest project, everything worked perfectly, and suddenly, when I tried to recall the url in postman, I keep getting "404 not found". I was working on my old project with maven, trying to implement a rest project, everything worked perfectly, and suddenly, when I tried to recall the url in postman, I keep getting "404 not found". I don't know what really happened, because everything worked perfectly !!我不知道到底发生了什么,因为一切都很完美!

what I did, is in EJB folder I created three packages one for entities one for the interface and the other for the service then in the webproject I created a package that contains two files, one for the webservice and the other for the rest activator !我所做的是在 EJB 文件夹中创建了三个包,一个用于实体,一个用于接口,另一个用于服务,然后在 web 项目中,我创建了一个 package,其中包含两个文件,一个用于 web 服务,另一个用于 rest 激活器!

this is the webservice file:这是网络服务文件:

package crm.webservices;

import java.util.List;

import javax.ejb.EJB;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import crm.entities.Product;
import crm.impl.ProductImpl;




@Path("products")


public class ProductWs   {

    @EJB
    ProductImpl productImpl;
      private final String status = "{\"status\":\"ok\"}";


    @GET
    @Produces(MediaType.APPLICATION_JSON)
    @Path("allproducts")
    public List<Product> getProducts()
    {
        return productImpl.allProducts();
    }
}

the second file:第二个文件:

package crm.webservices;

import javax.ejb.Stateless;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;

@ApplicationPath("api")
@Stateless
public class RestActivator extends Application {

}

I'm new with Maven, and I have no idea what really happened because as I mentioned, eveything was okey.我是 Maven 的新手,我不知道到底发生了什么,因为正如我所提到的,一切都很好。 anyone can help me, I'm stuck here for about 3 hours !!任何人都可以帮助我,我被困在这里大约 3 个小时!

You have your application path defined as:您将应用程序路径定义为:

@ApplicationPath("api")

And you're not using it on your cURL, it should be:而且您没有在 cURL 上使用它,它应该是:

http://localhost:9080/projetcrm-web/api/products/allproducts

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 尝试从JSP表单调用servlet时出现404错误 - getting 404 error when trying to call servlet from JSP form 找不到404的Guice Servlet调用 - Guice Servlet call getting 404 Not Found 尝试致电服务时出现404错误 - Getting 404 error while trying to call a service 尝试将 Java 应用程序推送到 Cloud Foundry 时收到 404 Not Found 错误消息 - Getting 404 Not Found error message when trying to push a Java application to Cloud Foundry 当我尝试测试rest-api不能正常工作时,邮递员中的所有方法都无法找到 - When i'm trying to test rest-api is not working any methods all methods in postman is getting back and not found Postman:“状态”:404,“错误”:“未找到”,“消息”:“未找到”, - Postman :“status”: 404, “error”: “Not Found”, “message”: “Not Found”, 尝试访问WebSocket时收到错误404 - Getting error 404 when trying to reach a websocket "获取资源未找到 404 即使 URL 是正确的 spring boot" - Getting resource not found 404 even URL is correct spring boot 尝试通过URL访问tomcat中的xml文件,出现404错误 - Trying to access xml file in tomcat via URL, getting 404 error 使用 POSTMAN 访问 Spring RestApi(找不到 404) - Accessing Spring RestApi using POSTMAN (404 not found)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM