springboot 启动发现放在其他包里面的controller不被识别

  1. 加module的时候,一定要和启动类是同一个父
    检查

    com.xxx
    xxx-parent
    1.0-SNAPSHOT

    是不是一样的。
  2. 启动类的注解加下面

@SpringBootApplication(scanBasePackages = {“com.xxx”})
@MapperScan({“com.xxx.**.mapper”})
放在另外的包里的controller要在这样的package目录下面。应该可以扫描到;

如果启动后,发现还是不能扫描在其他包里面的controller, 我最终做了一个事情就ok了,就是在启动类的包里面加上对那个包的引用;在pom.xml加好如下:

com.xxx 含那controller的包名 1.0-SNAPSHOT 再启动 就可以了。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个简单的EAV模型的CRUD操作的Controller示例: ```java @RestController @RequestMapping("/eav") public class EavController { @Autowired private EavService eavService; @PostMapping("/entity") public ResponseEntity<Entity> createEntity(@RequestParam String type, @RequestParam String name) { Entity entity = eavService.createEntity(type, name); return ResponseEntity.ok(entity); } @PostMapping("/attribute") public ResponseEntity<Attribute> createAttribute(@RequestParam String name) { Attribute attribute = eavService.createAttribute(name); return ResponseEntity.ok(attribute); } @PostMapping("/value") public ResponseEntity<Value> createValue(@RequestParam Long entityId, @RequestParam Long attributeId, @RequestParam String value, @RequestParam String type) { Entity entity = eavService.getEntity(entityId); Attribute attribute = eavService.getAttribute(attributeId); Value val = eavService.createValue(entity, attribute, value, type); return ResponseEntity.ok(val); } @GetMapping("/values") public ResponseEntity<List<Value>> getValues(@RequestParam Long entityId, @RequestParam Long attributeId) { Entity entity = eavService.getEntity(entityId); Attribute attribute = eavService.getAttribute(attributeId); List<Value> values = eavService.getValues(entity, attribute); return ResponseEntity.ok(values); } // ... } ``` 在Controller中,我们使用了EavService中的方法来实现EAV模型的CURD操作。在POST请求中,我们使用@RequestParam注解来获取请求参数;在GET请求中,我们使用@RequestParam注解来获取查询参数。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值