Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

259
Vistas
How do I change the server name in the links in a Spring RepositoryRestResource?

I've got a simple RepositoryRestResource based off of the guides on spring.io

@RepositoryRestResource(collectionResourceRel = "people", path = "people")
public interface PersonRepository extends PagingAndSortingRepository<Person, Long>{

    List<Person> findByLastName(@Param("name")  String lastName);

}

This does indeed work, as my REST client returns

{
  "_links" : {
    "people" : {
      "href" : "http://127.0.0.1:8080/people{?page,size,sort}",
      "templated" : true
    },
    "profile" : {
      "href" : "http://127.0.0.1:8080/profile"
    }
  }
}

But my question is, where does the http://127.0.0.1:8080 part of the _links come from and how can I change it? When my application goes to production (or any of my environments, like local or dev), I'd rather be able to see something like http://api.mydomain.com.

If it matters, I'm compiling my program with mvn package and running it as a standalone jar on the server.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

The host and port of your URL are figured out by using HttpServletRequest#getRequestURL (or getRequestURI). So it will always reflect the host and port used by the client when performing the request.

Once you deploy that as api.yourdomain.com, this is what you'll get in the link URLs.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda