Inject ResourceConfig instance (not class) into Jersey

If you inject the class (via a servlet parameter) it seems that
Jersey tries to create all the beans for you (and fails). I thought
it was supposed to work (according to the docs), so I'm a bit confused
but the sample now has Spring DI and the tests pass.

Fixes gh-1981
This commit is contained in:
Dave Syer
2014-11-22 17:16:21 +00:00
parent e56a1ba561
commit 9f7bd0cddc
4 changed files with 39 additions and 9 deletions

View File

@@ -19,19 +19,19 @@ package sample.jersey;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
@Path("/hello")
public class Endpoint {
@Value("${message:World}")
private String msg;
@Autowired
private Service service;
@GET
public String message() {
return "Hello " + this.msg;
return "Hello " + this.service.message();
}
}