我有在NoteService接口中定义的调用方法,该方法的实现在NoteImpl类中。我正在尝试从Refresh类访问此方法,但出现此错误
Parameter 3 of constructor in com.new.macro.rest.Refresh required a bean of type 'com.new.macro.unity.processorService' that could not be found.
Action:Consider defining a bean of type 'com.new.macro.unity.NoteService' in your configuration.
我需要帮助解决此错误。
这是我尝试从call
访问NoteImpl class
方法的地方,是我的Refresh类>
package com.new.macro.rest; @Component public class Refresh implements BaseService { private final NoteService<Inbuild> iNoteService; public Refresh(final NoteService iNoteService) { this.iNoteService = iNoteService; } @PUT public String firstRefresh() { iNoteService.call(Types); return RefreshStatus.STARTED.toJsonResponse(); }
这里是带有
call method functionality
的NoteImpl类
@Configuration public abstract class NoteImpl implements NoteService{ private static final Logger LOGGER = LogManager.getLogger(NoteImpl.class); private final RestTemplate restTemplate; private final String Url; public NoteImpl( RestTemplate restTemplate,@Value("${url}") String Url){ this.restTemplate = restTemplate; this.Url = Url; } public void call(Set<Inbuild> Types, String Url) { Set<String> results = new HashSet<>(); \\ Remaining functionality } }
这里是界面
package com.new.macro.unity;
import java.util.Set;
public interface NoteService<T> {
void call(Set<? extends T> Types);
}
我有在NoteService接口中定义的调用方法,该方法的实现在NoteImpl类中。我正在尝试从Refresh类访问此方法,但出现此错误...
在构造函数的头上添加@Autowired
注释:
假定所有这些类都经过类路径扫描:-NoteImpl
不应该是抽象的-NoteImpl
应该注释为@Component
,而不是@Configuration
。配置类是创建bean的类
[要解决此问题,请不要将NoteImpl保留为抽象类-无法实例化抽象类。那应该解决问题。尽管@Configuration可以工作(因为它使用@Component进行元注释),但是@Service在这里有意义。