当我运行main类时会出错。
错误:
Action:
Consider defining a bean of type 'seconds47.service.TopicService' in your configuration.
Description:
Field topicService in seconds47.restAPI.topics required a bean of type 'seconds47.service.TopicService' that could not be found
public interface TopicService {
TopicBean findById(long id);
TopicBean findByName(String name);
void saveTopic(TopicBean topicBean);
void updateTopic(TopicBean topicBean);
void deleteTopicById(long id);
List<TopicBean> findAllTopics();
void deleteAllTopics();
public boolean isTopicExist(TopicBean topicBean);
}
@RestController
public class topics {
@Autowired
private TopicService topicService;
@RequestMapping(path = "/new_topic2", method = RequestMethod.GET)
public void new_topic() throws Exception {
System.out.println("new topic JAVA2");
}
}
public class TopicServiceImplementation implements TopicService {
@Autowired
private TopicService topicService;
@Autowired
private TopicRepository topicRepository;
@Override
public TopicBean findById(long id) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public TopicBean findByName(String name) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void saveTopic(TopicBean topicBean) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void updateTopic(TopicBean topicBean) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void deleteTopicById(long id) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public List<TopicBean> findAllTopics() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void deleteAllTopics() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public boolean isTopicExist(TopicBean topicBean) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}
主类:
@SpringBootApplication(exclude = {SecurityAutoConfiguration.class })
@ComponentScan(basePackages = {"seconds47"})
@EnableJpaRepositories("seconds47.repository")
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
我的包裹是这样的:
seconds47
seconds47.beans
seconds47.config
seconds47.repository
seconds47.restAPI
seconds47.service
类必须具有@component
注释或其派生(如@service
、@repository
等)才能被组件扫描识别为Spring bean。因此,如果您将@component
添加到类中,它应该可以解决您的问题。
描述:com.mongotest.demo.seeder中构造函数的参数0需要类型为“com.mongotest.repositories.studentrepository”的bean,但找不到该bean。 pom.xml
我有一个Java Spring Boot项目,我正在其中创建一个post请求。代码如下所示: 主要: 但是,当我运行该项目时,我会得到以下错误: 感谢您对此的任何帮助!非常感谢,
下午好,我正在尝试使用Spring Boot运行SOAP服务,但出现以下错误: 应用程序启动失败 描述: 我知道也许这应该是个愚蠢的错误,但我看不出来 附件MI代码: SpringBootSoapApp.java ClienteServiceImpl.java client.xsd 应用程序.属性 我的项目结构 我试图遵循以下示例:https://www.javaspringclub.com/pu
我有 ProductController.java ProductService.java ProductServiceImpl.java 这是我的错误: 我有完整日志:https://gist.github.com/donhuvy/b918e20eeeb7cbe3c4be4167d066f7fd 这是我的完整源代码https://github.com/donhuvy/accounting/com