sunchenbin / A.CTable-Frame

A.CTable是一个基于Spring和Mybatis的Maven项目,actable 支持springboot,增强了Mybatis的功能,通过配置model注解的方式来创建表,修改表结构,目前仅支持Mysql ,码云上有各个发布版本的记录:https://gitee.com/sunchenbin/mybatis-enhance/releases
https://blog.csdn.net/sun5769675/article/details/74779640
Apache License 2.0
125 stars 57 forks source link

Mybatis-Plus 建表可以,但是使用报错 #16

Open carl0804 opened 3 years ago

carl0804 commented 3 years ago
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.example.demo.mapper.UserMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@javax.annotation.Resource(shareable=true, lookup="", name="", description="", authenticationType=CONTAINER, type=java.lang.Object.class, mappedName="")}
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1717)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1273)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1227)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:521)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:497)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:650)
    at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:228)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:318)
    ... 65 more
application.properties

mybatis-plus.mapper-locations=classpath*:com/gitee/sunchenbin/mybatis/actable/mapping/*/*.xml
#控制台打印
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl

# actable的配置信息
actable.table.auto=update
actable.model.pack=com.example.demo.entity
actable.database.type=mysql
pom.xml

 <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.4.2</version>
 </dependency>
<dependency>
            <groupId>com.gitee.sunchenbin.mybatis.actable</groupId>
            <artifactId>mybatis-enhance-actable</artifactId>
            <version>1.5.0.RELEASE</version>
            <exclusions>
                <exclusion>
                    <groupId>com.baomidou</groupId>
                    <artifactId>mybatis-plus-annotation</artifactId>
                </exclusion>
          </exclusions>
 </dependency>
@SpringBootApplication
@MapperScan("com.gitee.sunchenbin.mybatis.actable.dao.*")
@ComponentScan(basePackages = {"com.gitee.sunchenbin.mybatis.actable.manager.*"})
public class MpTableApplication {

    public static void main(String[] args) {
        SpringApplication.run(MpTableApplication.class, args);
    }

}
Mapper类
public interface UserMapper extends BaseMapper<User> {
}

public interface IUserService extends IService<User> {
}

@Service
@Transactional(rollbackFor = Exception.class)
public class IUserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {

    @Resource
    private UserMapper userMapper;
}

Service层使用,报同样的错

carl0804 commented 3 years ago

好像运行application启动类不报错,但是ApplicationTests测试类里,调mapper或者service报错