Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

262
Views
¿Cómo cambio el nombre del servidor en los enlaces en Spring RepositoryRestResource?

Tengo un RepositoryRestResource simple basado en las guías de spring.io

 @RepositoryRestResource(collectionResourceRel = "people", path = "people") public interface PersonRepository extends PagingAndSortingRepository<Person, Long>{ List<Person> findByLastName(@Param("name") String lastName); }

Esto sí funciona, ya que mi cliente REST regresa

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

Pero mi pregunta es, ¿de dónde viene la parte http://127.0.0.1:8080 de los _links y cómo puedo cambiarla? Cuando mi aplicación pasa a producción (o cualquiera de mis entornos, como local o dev), prefiero poder ver algo como http://api.mydomain.com .

Si importa, estoy compilando mi programa con mvn package y ejecutándolo como un contenedor independiente en el servidor.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

El host y el puerto de su URL se calculan utilizando HttpServletRequest#getRequestURL (o getRequestURI ). Por lo tanto, siempre reflejará el host y el puerto utilizados por el cliente al realizar la solicitud.

Una vez que implemente eso como api.yourdomain.com , esto es lo que obtendrá en las URL del enlace.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!