缺少依赖

时间:2017-06-19 10:21:00

标签: 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: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

我的springbean.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 {

    }

1 个答案:

答案 0 :(得分:0)

经过长时间的试验后,问题得到解决。 在root包初始配置类中,我添加了@componentScan,修复了这个问题。服务器已启动并正在运行。