[英]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.