mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-22 07:45:49 +00:00
Refactor: Use environment variables for URLs and @Autowired for injection
Instead of hardcoding URLs for owners/createOrUpdateOwnerForm and pets/createOrUpdatePetForm in the code, introduce environment variables for these values. Removed the static final type to allow injection. Also, replaced constructor injection with @Autowired annotation for OwnerRepository to reduce lines of code.
This commit is contained in:
parent
d1b096d6ca
commit
a079a97c1e
3 changed files with 5 additions and 1 deletions
|
@ -32,6 +32,8 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,8 @@ import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
|
|
||||||
|
|
|
@ -26,4 +26,4 @@ spring.web.resources.cache.cachecontrol.max-age=12h
|
||||||
|
|
||||||
# Environment Variables
|
# Environment Variables
|
||||||
views.owner.createOrUpdateForm=owners/createOrUpdateOwnerForm
|
views.owner.createOrUpdateForm=owners/createOrUpdateOwnerForm
|
||||||
views.pets.createOrUpdateForm=pets/createOrUpdatePetForm
|
views.pets.createOrUpdateForm=pets/createOrUpdatePetForm
|
||||||
|
|
Loading…
Reference in a new issue