我有一个基本的 SpringBoot 2.1.3.RELEASE 应用程序。使用 Spring Initializer、JPA、嵌入式 Tomcat、Thymeleaf 模板引擎,并将其打包为可执行的 JAR 文件。
我有这个 restController
@RestController
@RequestMapping("/api/v1/users")
public class UserResourceController extends ResourceController {
private static final Logger LOG = LoggerFactory.getLogger(UserResourceController.class);
@GetMapping(path = "/", consumes = "application/json", produces = "application/json")
@ResponseStatus(HttpStatus.OK)
public ResponseEntity<User> getUser(@RequestHeader(value = "Authorization") String authHeader) {
User user = authUserOnPath("/users", authHeader);
user.getApplicationSetup()
.setExchangeRateWithUSD(currencyService.getUSDRate(user.getApplicationSetup().getAppCcy()));
return ResponseEntity.ok().body(user);
}
}
还有这个:
@RestController
@RequestMapping("/api/v1/users/wallets")
public class WalletResourceController extends ResourceController {
@Autowired
private WalletService walletService;
/**
* Get user's wallets
*
* @param request
* @param id
* @return
*/
@GetMapping(path = "/", consumes = "application/json", produces = "application/json")
public ResponseEntity<List<Wallet>> getUserWallets(@RequestHeader(value = "Authorization") String authHeader) {
User user = authUserOnPath("/users/wallets", authHeader);
List<Wallet> wallets = userService.getWallets(user);
return ResponseEntity.ok().cacheControl(CacheControl.maxAge(5, TimeUnit.MINUTES)).body(wallets);
}
访问时一切正常:
GET http://127.0.0.1:1133/myApp/api/v1/users
但我在访问时得到了 404:
GET http://127.0.0.1:1133/myApp/api/v1/users/wallets
Cats萌萌
相关分类