我丢,创建了接口,没实现就给我报错~~~

报错信息长这样子,又臭又长,英文一塌糊塌的我只认出了那个自己写的”helloService”和经常见过的“could not be found”

Description:

A component required a bean of type 'cn.hello.service.HelloService' that could not be found.


Action:

Consider defining a bean of type 'cn.hello.service.HelloService' in your configuration.

2020-06-22 11:28:22.635  WARN 6372 --- [           main] o.s.boot.SpringApplication               : Unable to close ApplicationContext

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.admin.SpringApplicationAdminJmxAutoConfiguration': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Initialization of bean failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry' available
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:603) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]

找不到?莫非少了注解~那先瞅瞅那个叫做“Helloservice"的东东

public interface HelloService {

    int insert(List<Hello> list);

    int del(int[] ids);
}

两个方法,没毛病,那么简介简单简陋~再瞅瞅它的实现类:

@Service
public class HelloServiceImpl{
    @Resource
    private HelloMapper helloMapper;

    public int insert(List<Hello> list){
        return this.helloMapper.insert(list);
    }

    public int del(int[] ids){
        return this.helloMapper.del(ids);
    }
}

细心的小哥眼睛这么一瞥就发现原来没写”implements HelloService“,加上去在运行就正常了

@Service
public class HelloServiceImpl implements HelloService {
    @Resource
    private HelloMapper helloMapper;

    public int insert(List<Hello> list){
        return this.helloMapper.insert(list);
    }

    public int del(int[] ids){
        return this.helloMapper.del(ids);
    }
}

这个是我批量插入和批量删除的方法,一开始没写接口,直接写了个类调用一下mapper里面的方法,一帆风顺~后来我想着有个接口可能看着更高大上一点,没想弄巧成拙。作为一个代码的搬运工,一开始我就应该创建接口,接着写实现类,一步一jio印,将一行一行的代码稳妥的放置在合理的位置。它好我也好,hhh------以后再细心些吧!
<------------希望我入过的歧途,能对你有帮助----------->

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值