0
我有基於斷指南上spring.io簡單RepositoryRestResource如何更改Spring RepositoryRestResource中鏈接的服務器名稱?
@RepositoryRestResource(collectionResourceRel = "people", path = "people")
public interface PersonRepository extends PagingAndSortingRepository<Person, Long>{
List<Person> findByLastName(@Param("name") String lastName);
}
這確實工作,我的REST客戶端返回
{
"_links" : {
"people" : {
"href" : "http://127.0.0.1:8080/people{?page,size,sort}",
"templated" : true
},
"profile" : {
"href" : "http://127.0.0.1:8080/profile"
}
}
}
但我的問題是,在什麼地方http://127.0.0.1:8080
_links
的一部分來自我如何更改它?當我的應用程序投入生產(或任何我的環境,如本地或開發)時,我寧願能夠看到像http://api.mydomain.com
之類的東西。
如果很重要,我正在編譯我的程序mvn package
並將其作爲獨立的jar在服務器上運行。
確實如此!我被拋棄了,因爲當我們部署時,我們實際上是在Docker容器中部署一個nginx反向代理服務器,所以它總是看起來像localhost:8080到Spring。 我改變了nginx的配置,按照http://stackoverflow.com/questions/40791634/original-url-when-using-nginx-container-as-reverse-proxy,它按預期工作。 – Mike