我有下一个休息服务:
@ApplicationPath("geo")
@Path("weather")
public class MainResource extends Application {
@Inject
private MainDep dep;
@GET
public String printGotIt() {
return "Got it!";
}
@GET
@Path("propaganda")
public String printPropaganda() {
return dep.printPropaganda();
}
}
MainDep 依赖代码:
public class MainDep {
public String printPropaganda() {
return "Interesting enterprise";
}
}
当我尝试在以下 url 上使用资源时:host:port/root/geo/weather GlassFish 抛出了 javax.servlet.ServletException:
type Exception report
messageInternal Server Error
descriptionThe server encountered an internal error that prevented it from fulfilling this request.
exception
`javax.servlet.ServletException: Servlet.init() for servlet com.app.weather.rs.MainResource threw exception
root cause`
A MultiException has 1 exceptions. They are:
1. org.glassfish.hk2.api.UnsatisfiedDependencyException: There was no object available for injection at Injectee(requiredType=MainDep,parent=MainResource,qualifiers={}),position=-1,optional=false,self=false,unqualified=null,22064320)
root cause
org.glassfish.hk2.api.UnsatisfiedDependencyException: There was no object available for injection at Injectee(requiredType=MainDep,parent=MainResource,qualifiers={}),position=-1,optional=false