無法運行起來
其中數據庫配置
<table?tableName="dw_admin"?domainObjectName="AdminDO"?enableCountByExample="false" ?enableSelectByExample="false"?enableUpdateByExample="false"?enableDeleteByExample="false" ?selectByExampleQueryId="false"></table>
????java代碼
@SpringBootApplication(scanBasePackages?=?{"com.miaoshaproject"}) @RestController @MapperScan("com.miaoshaproject.dao") public?class?App { ????@Autowired ????private?AdminDOMapper?adminDOMapper; ????@RequestMapping("/") ????public?String?home(){ ????????AdminDO?adminDO?=?adminDOMapper.selectByPrimaryKey(1); ????????if?(adminDO?==?null){ ????????????return?"Hello?world?!"; ????????} ????????else{ ????????????return?adminDO.getUserName(); ????????} ????} ????public?static?void?main(?String[]?args?)?{ ????????System.out.println(?"Hello?World!"?); ????????SpringApplication.run(App.class,?args); ????} }
啟動報錯
Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'app': Unsatisfied dependency expressed through field 'adminDOMapper'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'adminDOMapper' defined in file [/Users/pro/Desktop/java_project/target/classes/com/miaoshaproject/dao/AdminDOMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [/Users/pro/Desktop/java_project/target/classes/mapping/AdminDOMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.miaoshaproject.dao.AdminDOMapper.BaseResultMap
2019-05-08
我也有這個問題 一模一樣
2019-04-25
刪掉生成的文件,重新執(zhí)行