Java 缺少依赖项
简单的基本获取api和获取字符串数据工作正常。后来我增强了该类以自动连接依赖项,我得到了一个错误Java 缺少依赖项,java,web-services,rest,spring-boot,jersey,Java,Web Services,Rest,Spring Boot,Jersey,简单的基本获取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:
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
myspringbean.xml
与PIJSONSerializer的公共接口{
}
@组成部分
公共类DefaultSerialization实现ToApiJsonSerializer{
私人最终GoogleGsonSerializerHelper助手;
@自动连线
公共默认值为PIJSONSerializer(
最终GoogleGsonSerializerHelper助手){
this.helper=helper;
}
}
@服务
公开最后一堂课googlesonserializerhelper{
}
经过长时间的试验,问题得到了解决。
在根包初始配置类中,我添加了@componentScan,这解决了这个问题。服务器已启动并正在运行
ToApiJsonSerializer
是Springbean吗?
<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 {
}