admin管理员组文章数量:1356758
When I try to test the database briefly using the following code (additions: My database has only one id
field in the corresponding table), it reports an error.
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(description = "Node")
@TableName(keepGlobalPrefix = true, value = "node")
public class Node {
@TableId(type = IdType.NONE)
private Integer id;
}
error info:
Error creating bean with name 'xxxController' defined in file []. Unsatisfied dependency expressed through constructor parameter 0; nested exception is .springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'xxxServiceImpl': Unsatisfied dependency expressed through field 'baseMapper'; nested exception is .springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'xxxMapper' defined in file []: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is .springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is .springframework.beans.BeanInstantiationException: Failed to instantiate [.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is .springframework.core.NestedIOException: Failed to parse mapping resource: 'file [xxx]'; nested exception is java.lang.StringIndexOutOfBoundsException: begin 0, end -1, length 0
But all I have to do is add a name
field (even though it doesn't exist in the corresponding table) and the code works fine.
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(description = "Node")
@TableName(keepGlobalPrefix = true, value = "node")
public class Node {
@TableId(type = IdType.NONE)
private Integer id;
private String name;
}
Although this problem doesn't affect my program in any way, I'd still like to know why it's happening.
Just in case, I'll post the general information about Contrller
, Service
, and Mapper
(none of them are actually used much).
Controller:
@Api(tags = "dataCatalog")
@RequestMapping("/api/dataCatalog")
@RestController
@AllArgsConstructor
public class DataCatalogController {
private final NodeService nodeService;
@GetMapping("/getDataCatalog")
@ApiOperation("getDataCatalog")
public Result<List<Node>> getDataCatalogNode() {
return Result.success(nodeService.list());
}
}
Service:
public interface NodeService extends IService<Node> {
}
ServiceImpl:
@Service
@RequiredArgsConstructor
public class NodeServiceImpl extends ServiceImpl<NodeMapper, Node> implements NodeService {
}
Mapper:
@Mapper
public interface NodeMapper extends BaseMapper<Node> {
}
Mapper.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis//DTD Mapper 3.0//EN" ".dtd">
<mapper namespace="cn.workflow.business.modules.catalog.mapper.NodeMapper">
</mapper>
Finally, thanks a lot for answering
本文标签:
版权声明:本文标题:java - Strange error about entity class: Error creating bean with name 'xxxController' defined in file [] - Stac 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744058823a2583746.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论