简单的基本获取 api 并获取字符串数据工作正常。 后来我增强了类以自动连接依赖项,我收到一个错误.
2017-06-19 15:41:44.311 INFO 7808 --- [ main] c.s.j.api.core.PackagesResourceConfig : Scanning for root resource and provider classes in the packages:
com.praveen.praveen
2017-06-19 15:41:44.352 INFO 7808 --- [ main] c.s.j.api.core.ScanningResourceConfig : Root resource classes found:
class com.praveen.praveen.api.ApiResource
2017-06-19 15:41:44.353 INFO 7808 --- [ main] c.s.j.api.core.ScanningResourceConfig : No provider classes found.
2017-06-19 15:41:44.450 INFO 7808 --- [ main] c.s.j.s.s.c.servlet.SpringServlet : Using default applicationContext
2017-06-19 15:41:44.459 INFO 7808 --- [ main] com.sun.jersey.spi.inject.Errors : The following errors and warnings have been detected with resource and/or provider classes:
SEVERE: Missing dependency for constructor public com.praveen.praveen.api.TreesApiResource(com.praveen.praveen.support.serialization.ToApiJsonSerializer) at parameter index 0
2017-06-19 15:41:45.084 ERROR 7808 --- [ main] c.s.j.s.s.c.servlet.SpringServlet : Exception occurred when intialization
com.sun.jersey.spi.inject.Errors$ErrorMessagesException: null
我的春豆.xml
<context:exclude-filter expression="org.springframework.stereotype.Controller"
type="annotation" />
<context:exclude-filter
expression="org.springframework.context.annotation.Configuration"
type="annotation" />
</context:component-scan>
public interface ToApiJsonSerializer<T> {
}
@Component
public class DefaultSerialization<T> implements ToApiJsonSerializer<T>{
private final GoogleGsonSerializerHelper helper;
@Autowired
public DefaultToApiJsonSerializer(
final GoogleGsonSerializerHelper helper) {
this.helper = helper;
}
}
@Service
public final class GoogleGsonSerializerHelper {
}
经过长时间的试用,问题得到了修复。在根包初始配置类中,我添加了@componentScan这解决了问题。服务器已启动并正在运行。