java怎样给service分类_java – 考虑在配置中定义一个’service’类型的bean [Spring boot]...

我运行主类时遇到错误.

错误:

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

TopicService接口:

public interface TopicService {

TopicBean findById(long id);

TopicBean findByName(String name);

void saveTopic(TopicBean topicBean);

void updateTopic(TopicBean topicBean);

void deleteTopicById(long id);

List 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 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.

}

}

其他类也定义了.尽管在主类中声明了componentScan,我不知道它为什么会抛出.

主要课程:

@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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值