此处记录三个错误:
一、jar中没有主清单属性,打包以后运行报错:
这是一个gateway模块,包含了启动类,因为在pom文件中没有指定,所以报错:在该模块的pom文件中加入如下代码:com.xxxxx.gateway.GatewayApplication
为该模块启动类的包路径
<build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><configuration><mainClass>com.xxxxx.gateway.GatewayApplication</mainClass><includeSystemScope>true</includeSystemScope></configuration></plugin></plugins></build>
成功运行
二、找不到 / 无法创建相关的Mapper、Service等、报错expected at least 1 bean which qualifies as autowire candidate. Dependency annotations:
这个是因为该模块的启动类上面没有加扫描注解:
通过加上@MapperScan({"com.xxx.mpg.*.mapper"})
注解,表明mapper所在的路径即可
三、成功运行jar包以后、访问相关接口、报错302,重定向请求login接口,
百度原因可能是:spring security框架未通过认证而将请求重定向至登录页面!因为contract模块中的接口没有涉及springsecurity的认证,而token令牌是通过之前的中继完成的,所以在启动类上的注解增加(exclude = { SecurityAutoConfiguration.class })
排除Security框架:
至此,项目成功打包并且运行、不过坑还在后面
【问题】请求莫名重定向至login的问题
SpringBoot中报错expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: