2017-06-19 224 views
0

简单基本获取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 { 

    } 
+0

ToApiJsonSerializer是Spring Bean吗? – Strelok

回答

0

长期试验后问题得到了解决。 在根包初始配置类中,我添加了@componentScan这个问题。服务器已启动并正在运行。