尚庭公寓-----day1----@MapperScan爆红问题
尚庭公寓---------@MapperScan爆红问题
解决方案一:在common模块的pom文件下添加web-admin模块
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>com.nie</groupId><artifactId>lease</artifactId><version>1.0-SNAPSHOT</version></parent><artifactId>common</artifactId><properties><maven.compiler.source>17</maven.compiler.source><maven.compiler.target>17</maven.compiler.target><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding></properties><dependencies><!--mybatis-plus--><dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId></dependency><!--mysql驱动--><dependency><groupId>com.mysql</groupId><artifactId>mysql-connector-j</artifactId></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId></dependency><dependency><groupId>com.nie</groupId><artifactId>web-admin</artifactId><version>1.0-SNAPSHOT</version></dependency></dependencies>
</project>
但是这样会出现另外一个错误 : 这是循环依赖的错误
Edge between 'Vertex{label='com.nie:web-admin:1.0-SNAPSHOT'}' and 'Vertex{label='com.nie:common:1.0-SNAPSHOT'}' introduces to cycle in the graph com.nie:common:1.0-SNAPSHOT --> com.nie:web-admin:1.0-SNAPSHOT --> com.nie:common:1.0-SNAPSHOT
解决方案二 : 在启动类上面添加@ComponentScan
(推荐)
package com.nie.lease;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;@SpringBootApplication
@ComponentScan(basePackages ={"com.nie.lease.common","com.nie.lease.web.admin.*"} )
public class AdminWebApplication {public static void main(String[] args) {SpringApplication.run(AdminWebApplication.class, args);}
}
解决方案三:直接在每个mapper类上面添加@Mapper注解
package com.nie.lease.web.admin.mapper;import com.nie.lease.model.entity.ApartmentFacility;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;/**
* @author liubo
* @description 针对表【apartment_facility(公寓&配套关联表)】的数据库操作Mapper
* @createDate 2023-07-24 15:48:00
* @Entity com.atguigu.lease.model.ApartmentFacility
*/
@Mapper
public interface ApartmentFacilityMapper extends BaseMapper<ApartmentFacility> {}