环境:netbeans30、JDK21、mongodb8.2.3单机模式
导入netbeans即可
如果用JSF时,出现如下报错:There is no web component by the name of jakarta.ws.rs.core.Application
解决方法:
- 在web.xml中,注释掉
<servlet-mapping>
<servlet-name>jakarta.ws.rs.core.Application</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>
- 增加如下代码,即可。
import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.core.Application;
/**
* Configures Jakarta RESTful Web Services for the application.
*/
@ApplicationPath("/api")
public class JakartaRestConfiguration extends Application {
}