我将我的 Spring Boot 项目更新到了 2.2 版。我正在使用 HATEAOS,所以我必须转换应用程序的几个部分,如此处所述https://spring.io/blog/2019/03/05/spring-hateoas-1-0-m1-released
我只有一个问题BaseUriLinkBuilder。我有这门课:
/**
* Utility class that fix the URI created adding the base path.
* {@linkplain "https://github.com/spring-projects/spring-hateoas/issues/434}"
*
* @author Daniele Renda
*/
@Service
@Log4j2
public class BasePathAwareLinks {
private final URI contextBaseURI;
private final URI restBaseURI;
@Autowired
public BasePathAwareLinks(ServletContext servletContext, RepositoryRestConfiguration config) {
contextBaseURI = URI.create(servletContext.getContextPath());
restBaseURI = config.getBasePath();
}
public WebMvcLinkBuilder underBasePath(WebMvcLinkBuilder linkBuilder) {
try {
URI uri = linkBuilder.toUri();
URI origin = new URI(uri.getScheme(), uri.getAuthority(), null, null, null);
URI suffix = new URI(null, null, uri.getPath(), uri.getQuery(), uri.getFragment());
return BaseUriLinkBuilder.create(origin).slash(contextBaseURI).slash(restBaseURI).slash(suffix);
} catch (URISyntaxException e) {
log.error("", e);
}
return null;
}
}
但似乎BaseUriLinkBuilder已经不存在了。我没有找到任何有关此更改的参考。任何提示如何解决问题?