@ -1358,10 +1358,10 @@ example, using the qualifier notation, the following Java code
@@ -1358,10 +1358,10 @@ example, using the qualifier notation, the following Java code
----
public class TransactionalService {
@Transactional("order")
@Transactional(transactionManager = "order")
public void setSomething(String name) { ... }
@Transactional("account")
@Transactional(transactionManager = "account")
public void doSomething() { ... }
}
----
@ -1403,13 +1403,13 @@ defining the following annotations
@@ -1403,13 +1403,13 @@ defining the following annotations
@ -8109,7 +8109,7 @@ of the cache associated with the annotated method:
@@ -8109,7 +8109,7 @@ of the cache associated with the annotated method:
[source,java,indent=0]
[subs="verbatim,quotes"]
----
@Cacheable("books")
@Cacheable(cacheNames = "books")
public Book findBook(ISBN isbn) {...}
----
@ -8130,7 +8130,7 @@ the cached method was not actually executed.
@@ -8130,7 +8130,7 @@ the cached method was not actually executed.
[source,java,indent=0]
[subs="verbatim,quotes"]
----
@Cacheable({"books", "isbns"})
@Cacheable(cacheNames = ""books", "isbns"})
public Book findBook(ISBN isbn) {...}
----
@ -8177,7 +8177,7 @@ caching (while the rest are used only by the method logic). For example:
@@ -8177,7 +8177,7 @@ caching (while the rest are used only by the method logic). For example:
[source,java,indent=0]
[subs="verbatim,quotes"]
----
@Cacheable("books")
@Cacheable(cacheNames = "books")
public Book findBook(ISBN isbn, boolean checkWarehouse, boolean includeUsed)
@ -1029,8 +1029,8 @@ that centralizes the common test configuration like this:
@@ -1029,8 +1029,8 @@ that centralizes the common test configuration like this:
@ -1457,7 +1457,7 @@ TestContext Framework is enabled automatically if Groovy is on the classpath.
@@ -1457,7 +1457,7 @@ TestContext Framework is enabled automatically if Groovy is on the classpath.
@RunWith(SpringRunner.class)
// ApplicationContext will be loaded from "/AppConfig.groovy" and
// "/TestConfig.groovy" in the root of the classpath
@ -1500,7 +1500,7 @@ The following listing demonstrates how to combine both in an integration test.
@@ -1500,7 +1500,7 @@ The following listing demonstrates how to combine both in an integration test.
@ -1691,14 +1691,14 @@ therefore __override__ (i.e., replace) those defined in __"base-config.xml"__.
@@ -1691,14 +1691,14 @@ therefore __override__ (i.e., replace) those defined in __"base-config.xml"__.
@RunWith(SpringRunner.class)
// ApplicationContext will be loaded from "/base-config.xml"
@ -1822,8 +1822,8 @@ Let's take a look at some examples with XML configuration and `@Configuration` c
@@ -1822,8 +1822,8 @@ Let's take a look at some examples with XML configuration and `@Configuration` c
@RunWith(SpringRunner.class)
// ApplicationContext will be loaded from "classpath:/app-config.xml"
@ -1843,7 +1843,7 @@ When `TransferServiceTest` is run, its `ApplicationContext` will be loaded from
@@ -1843,7 +1843,7 @@ When `TransferServiceTest` is run, its `ApplicationContext` will be loaded from
`dataSource` is defined three times: in the __production__ profile, the
__dev__ profile, and the __default__ profile.
By annotating `TransferServiceTest` with `@ActiveProfiles("dev")` we instruct the Spring
By annotating `TransferServiceTest` with `@ActiveProfiles(profiles = "dev")` we instruct the Spring
TestContext Framework to load the `ApplicationContext` with the active profiles set to
`{"dev"}`. As a result, an embedded database will be created and populated with test data,
and the `accountRepository` bean will be wired with a reference to the development
@ -1945,7 +1945,7 @@ integration test but using `@Configuration` classes instead of XML.
@@ -1945,7 +1945,7 @@ integration test but using `@Configuration` classes instead of XML.
StandaloneDataConfig.class,
JndiDataConfig.class,
DefaultDataConfig.class})
@ActiveProfiles("dev")
@ActiveProfiles(profiles = "dev")
public class TransferServiceTest {
@Autowired
@ -1971,7 +1971,7 @@ In this variation, we have split the XML configuration into four independent
@@ -1971,7 +1971,7 @@ In this variation, we have split the XML configuration into four independent
no profile is active
As with the XML-based configuration example, we still annotate `TransferServiceTest`
with `@ActiveProfiles("dev")`, but this time we specify all four configuration classes
with `@ActiveProfiles(profiles = "dev")`, but this time we specify all four configuration classes
via the `@ContextConfiguration` annotation. The body of the test class itself remains
completely unchanged.
@ -1993,7 +1993,7 @@ annotations) has been moved to an abstract superclass, `AbstractIntegrationTest`
@@ -1993,7 +1993,7 @@ annotations) has been moved to an abstract superclass, `AbstractIntegrationTest`
StandaloneDataConfig.class,
JndiDataConfig.class,
DefaultDataConfig.class})
@ActiveProfiles("dev")
@ActiveProfiles(profiles = "dev")
public abstract class AbstractIntegrationTest {
}
----
@ -2121,7 +2121,7 @@ be loaded using the specified resource protocol. Resource location wildcards (e.
@@ -2121,7 +2121,7 @@ be loaded using the specified resource protocol. Resource location wildcards (e.
@ -2211,13 +2211,13 @@ only the `"base.properties"` file as a test property source. In contrast, the
@@ -2211,13 +2211,13 @@ only the `"base.properties"` file as a test property source. In contrast, the
public class RestWebServiceTests extends AbstractWebTests {}
----
--
@ -2693,7 +2693,7 @@ The first code listing shows a JUnit 4 based implementation of the test class th
@@ -2693,7 +2693,7 @@ The first code listing shows a JUnit 4 based implementation of the test class th
----
@RunWith(SpringRunner.class)
// specifies the Spring configuration to load for this test fixture
// execute code that uses the test schema and test data
}
@ -3381,7 +3381,7 @@ grouped together within `@SqlGroup` for compatibility with Java 6 and Java 7.
@@ -3381,7 +3381,7 @@ grouped together within `@SqlGroup` for compatibility with Java 6 and Java 7.
// execute code that uses the test schema and test data
@ -3482,7 +3482,7 @@ be automatically rolled back by the `TransactionalTestExecutionListener` (see
@@ -3482,7 +3482,7 @@ be automatically rolled back by the `TransactionalTestExecutionListener` (see
}
@Test
@Sql("/test-data.sql")
@Sql(scripts = "/test-data.sql")
public void usersTest() {
// verify state in test database:
assertNumUsers(2);
@ -3719,7 +3719,7 @@ JUnit 4 based example of using Spring MVC Test:
@@ -3719,7 +3719,7 @@ JUnit 4 based example of using Spring MVC Test:
@ -43,11 +43,11 @@ it. By default `@CrossOrigin` allows all origins and the HTTP methods specified
@@ -43,11 +43,11 @@ it. By default `@CrossOrigin` allows all origins and the HTTP methods specified
[subs="verbatim,quotes"]
----
@RestController
@RequestMapping("/account")
@RequestMapping(path = "/account")
public class AccountController {
@CrossOrigin
@RequestMapping("/{id}")
@RequestMapping(path = "/{id}")
public Account retrieve(@PathVariable Long id) {
// ...
}
@ -66,10 +66,10 @@ It is also possible to enable CORS for the whole controller:
@@ -66,10 +66,10 @@ It is also possible to enable CORS for the whole controller:
@ -93,11 +93,11 @@ then combine attributes from both annotations to create merged CORS configuratio
@@ -93,11 +93,11 @@ then combine attributes from both annotations to create merged CORS configuratio
@ -497,7 +497,7 @@ and others.
@@ -497,7 +497,7 @@ and others.
@Controller
public class HelloWorldController {
@RequestMapping("/helloWorld")
@RequestMapping(path = "/helloWorld")
public String helloWorld(Model model) {
model.addAttribute("message", "Hello World!");
return "helloWorld";
@ -575,7 +575,7 @@ application that uses this annotation:
@@ -575,7 +575,7 @@ application that uses this annotation:
[subs="verbatim,quotes"]
----
@Controller
**@RequestMapping("/appointments")**
**@RequestMapping(path = "/appointments")**
public class AppointmentsController {
private final AppointmentBook appointmentBook;
@ -639,11 +639,11 @@ application shows a multi-action controller using `@RequestMapping`:
@@ -639,11 +639,11 @@ application shows a multi-action controller using `@RequestMapping`:
this.clinic = clinic;
}
**@RequestMapping("/")**
**@RequestMapping(path = "/")**
public void welcomeHandler() {
}
**@RequestMapping("/vets")**
**@RequestMapping(path = "/vets")**
public ModelMap vetsHandler() {
return new ModelMap(this.clinic.getVets());
}
@ -676,7 +676,7 @@ previous section that has been simplified with _composed_ `@RequestMapping` anno
@@ -676,7 +676,7 @@ previous section that has been simplified with _composed_ `@RequestMapping` anno
[subs="verbatim,quotes"]
----
@Controller
**@RequestMapping("/appointments")**
**@RequestMapping(path = "/appointments")**
public class AppointmentsController {
private final AppointmentBook appointmentBook;
@ -691,12 +691,12 @@ previous section that has been simplified with _composed_ `@RequestMapping` anno
@@ -691,12 +691,12 @@ previous section that has been simplified with _composed_ `@RequestMapping` anno
return appointmentBook.getAppointmentsForToday();
}
**@GetMapping("/{day}")**
**@GetMapping(path = "/{day}")**
public Map<String, Appointment> getForDay(@PathVariable @DateTimeFormat(iso=ISO.DATE) Date day, Model model) {
@ -785,7 +785,7 @@ to the value of a URI template variable:
@@ -785,7 +785,7 @@ to the value of a URI template variable:
[source,java,indent=0]
[subs="verbatim,quotes"]
----
@GetMapping("/owners/{ownerId}")
@GetMapping(path = "/owners/{ownerId}")
public String findOwner(**@PathVariable** String ownerId, Model model) {
Owner owner = ownerService.findOwner(ownerId);
model.addAttribute("owner", owner);
@ -807,7 +807,7 @@ template variable by name. You can specify it in the annotation:
@@ -807,7 +807,7 @@ template variable by name. You can specify it in the annotation:
[source,java,indent=0]
[subs="verbatim,quotes"]
----
@GetMapping("/owners/{ownerId}")
@GetMapping(path = "/owners/{ownerId}")
public String findOwner(**@PathVariable("ownerId")** String theOwner, Model model) {
public String findOwner(**@PathVariable** String ownerId, Model model) {
// implementation omitted
}
@ -833,7 +833,7 @@ A method can have any number of `@PathVariable` annotations:
@@ -833,7 +833,7 @@ A method can have any number of `@PathVariable` annotations:
public String findPet(**@PathVariable** String ownerId, **@PathVariable** String petId, Model model) {
Owner owner = ownerService.findOwner(ownerId);
Pet pet = owner.getPet(petId);
@ -882,7 +882,7 @@ name and the second - the regular expression. For example:
@@ -882,7 +882,7 @@ name and the second - the regular expression. For example:
public void handle(@PathVariable String version, @PathVariable String extension) {
// ...
}
@ -1031,7 +1031,7 @@ Below is an example of extracting the matrix variable "q":
@@ -1031,7 +1031,7 @@ Below is an example of extracting the matrix variable "q":
----
// GET /pets/42;q=11;r=22
@GetMapping("/pets/{petId}")
@GetMapping(path = "/pets/{petId}")
public void findPet(@PathVariable String petId, @MatrixVariable int q) {
// petId == 42
@ -1048,7 +1048,7 @@ specific to identify where the variable is expected to be:
@@ -1048,7 +1048,7 @@ specific to identify where the variable is expected to be:
@MatrixVariable(name="q", pathVar="ownerId") int q1,
@MatrixVariable(name="q", pathVar="petId") int q2) {
@ -1066,7 +1066,7 @@ A matrix variable may be defined as optional and a default value specified:
@@ -1066,7 +1066,7 @@ A matrix variable may be defined as optional and a default value specified:
----
// GET /pets/42
@GetMapping("/pets/{petId}")
@GetMapping(path = "/pets/{petId}")
public void findPet(@MatrixVariable(required=false, defaultValue="1") int q) {
// q == 1
@ -1081,7 +1081,7 @@ All matrix variables may be obtained in a Map:
@@ -1081,7 +1081,7 @@ All matrix variables may be obtained in a Map:
public String processSubmit(**@ModelAttribute("pet") Pet pet**, Model model, **BindingResult result**) { ... }
public String processSubmit(**@ModelAttribute(name = "pet") Pet pet**, Model model, **BindingResult result**) { ... }
----
Note, that there is a `Model` parameter in between `Pet` and `BindingResult`. To get
@ -1390,7 +1390,7 @@ this working you have to reorder the parameters as follows:
@@ -1390,7 +1390,7 @@ this working you have to reorder the parameters as follows:
[subs="verbatim,quotes"]
----
@PostMapping
public String processSubmit(**@ModelAttribute("pet") Pet pet**, **BindingResult result**, Model model) { ... }
public String processSubmit(**@ModelAttribute(name = "pet") Pet pet**, **BindingResult result**, Model model) { ... }
----
[NOTE]
@ -1463,14 +1463,14 @@ The following code snippet shows the usage:
@@ -1463,14 +1463,14 @@ The following code snippet shows the usage:
[subs="verbatim,quotes"]
----
@Controller
@RequestMapping("/pets")
@SessionAttributes("pet")
@RequestMapping(path = "/pets")
@SessionAttributes(names = "pet")
public class EditPetForm {
// ...
@GetMapping
public String setupForm(**@RequestParam("petId") int petId**, ModelMap model) {
public String setupForm(**@RequestParam(name = "petId") int petId**, ModelMap model) {
Pet pet = this.clinic.loadPet(petId);
model.addAttribute("pet", pet);
return "petForm";
@ -1501,7 +1501,7 @@ be bound to the value of the HTTP request body. For example:
@@ -1501,7 +1501,7 @@ be bound to the value of the HTTP request body. For example:
[source,java,indent=0]
[subs="verbatim,quotes"]
----
@PutMapping("/something")
@PutMapping(path = "/something")
public void handle(@RequestBody String body, Writer writer) throws IOException {
writer.write(body);
}
@ -1580,7 +1580,7 @@ response body (and not placed in a Model, or interpreted as a view name). For ex
@@ -1580,7 +1580,7 @@ response body (and not placed in a Model, or interpreted as a view name). For ex
[source,java,indent=0]
[subs="verbatim,quotes"]
----
@GetMapping("/something")
@GetMapping(path = "/something")
@ResponseBody
public String helloWorld() {
return "Hello World";
@ -1622,7 +1622,7 @@ so:
@@ -1622,7 +1622,7 @@ so:
[source,java,indent=0]
[subs="verbatim,quotes"]
----
@RequestMapping("/something")
@RequestMapping(path = "/something")
public ResponseEntity<String> handle(HttpEntity<byte[]> requestEntity) throws UnsupportedEncodingException {
public String processSubmit(**@ModelAttribute Pet pet**) { }
----
@ -1750,8 +1750,8 @@ using an URI template variable and a type converter. Here is an example:
@@ -1750,8 +1750,8 @@ using an URI template variable and a type converter. Here is an example:
[source,java,indent=0]
[subs="verbatim,quotes"]
----
@PutMapping("/accounts/{account}")
public String save(@ModelAttribute("account") Account account) {
@PutMapping(path = "/accounts/{account}")
public String save(@ModelAttribute(name = "account") Account account) {
// ...
}
----
@ -1775,8 +1775,8 @@ following the `@ModelAttribute` argument:
@@ -1775,8 +1775,8 @@ following the `@ModelAttribute` argument:
@ -1893,7 +1893,7 @@ use the `@SessionAttribute` annotation on a method parameter:
@@ -1893,7 +1893,7 @@ use the `@SessionAttribute` annotation on a method parameter:
[source,java,indent=0]
[subs="verbatim,quotes"]
----
@RequestMapping("/")
@RequestMapping(path = "/")
public String handle(**@SessionAttribute** User user) {
// ...
}
@ -1917,7 +1917,7 @@ access pre-existing request attributes created by a filter or interceptor:
@@ -1917,7 +1917,7 @@ access pre-existing request attributes created by a filter or interceptor:
[source,java,indent=0]
[subs="verbatim,quotes"]
----
@RequestMapping("/")
@RequestMapping(path = "/")
public String handle(**@RequestAttribute** Client client) {
// ...
}
@ -1991,8 +1991,8 @@ The following code sample demonstrates how to get the value of the `JSESSIONID`
@@ -1991,8 +1991,8 @@ The following code sample demonstrates how to get the value of the `JSESSIONID`
[source,java,indent=0]
[subs="verbatim,quotes"]
----
@RequestMapping("/displayHeaderInfo.do")
public void displayHeaderInfo(**@CookieValue("JSESSIONID")** String cookie) {
@RequestMapping(path = "/displayHeaderInfo.do")
public void displayHeaderInfo(**@CookieValue(name = "JSESSIONID")** String cookie) {
//...
}
----
@ -2027,9 +2027,9 @@ The following code sample demonstrates how to get the value of the `Accept-Encod
@@ -2027,9 +2027,9 @@ The following code sample demonstrates how to get the value of the `Accept-Encod
[source,java,indent=0]
[subs="verbatim,quotes"]
----
@RequestMapping("/displayHeaderInfo.do")
public void displayHeaderInfo(**@RequestHeader("Accept-Encoding")** String encoding,
**@RequestHeader("Keep-Alive")** long keepAlive) {
@RequestMapping(path = "/displayHeaderInfo.do")
public void displayHeaderInfo(**@RequestHeader(name = "Accept-Encoding")** String encoding,
**@RequestHeader(name = "Keep-Alive")** long keepAlive) {
//...
}
----
@ -2046,7 +2046,7 @@ with all header values.
@@ -2046,7 +2046,7 @@ with all header values.
====
Built-in support is available for converting a comma-separated string into an
array/collection of strings or other types known to the type conversion system. For
example a method parameter annotated with `@RequestHeader("Accept")` may be of type
example a method parameter annotated with `@RequestHeader(name = "Accept")` may be of type
`String` but also `String[]` or `List<String>`.
====
@ -2181,7 +2181,7 @@ Both `@ControllerAdvice` and `@RestControllerAdvice` can target a subset of cont
@@ -2181,7 +2181,7 @@ Both `@ControllerAdvice` and `@RestControllerAdvice` can target a subset of cont
public class AnnotationAdvice {}
// Target all Controllers within specific packages
@ -2332,7 +2332,7 @@ of such a controller method:
@@ -2332,7 +2332,7 @@ of such a controller method:
[source,java,indent=0]
[subs="verbatim,quotes"]
----
@RequestMapping("/quotes")
@RequestMapping(path = "/quotes")
@ResponseBody
public DeferredResult<String> quotes() {
DeferredResult<String> deferredResult = new DeferredResult<String>();
@ -2444,7 +2444,7 @@ Here is an example of that:
@@ -2444,7 +2444,7 @@ Here is an example of that:
[source,java,indent=0]
[subs="verbatim,quotes"]
----
@RequestMapping("/events")
@RequestMapping(path = "/events")
public ResponseBodyEmitter handle() {
ResponseBodyEmitter emitter = new ResponseBodyEmitter();
// Save the emitter somewhere..
@ -2503,7 +2503,7 @@ Here is an example of that:
@@ -2503,7 +2503,7 @@ Here is an example of that:
[source,java,indent=0]
[subs="verbatim,quotes"]
----
@RequestMapping("/download")
@RequestMapping(path = "/download")
public StreamingResponseBody handle() {
return new StreamingResponseBody() {
@Override
@ -3007,7 +3007,7 @@ through `Model` nor `RedirectAttributes`. For example:
@@ -3007,7 +3007,7 @@ through `Model` nor `RedirectAttributes`. For example:
[source,java,indent=0]
[subs="verbatim,quotes"]
----
@PostMapping("/files/{path}")
@PostMapping(path = "/files/{path}")
public String upload(...) {
// ...
return "redirect:files/{path}";
@ -3179,7 +3179,7 @@ application/atom+xml is shown below.
@@ -3179,7 +3179,7 @@ application/atom+xml is shown below.
private List<SampleContent> contentList = new ArrayList<SampleContent>();
@GetMapping("/content")
@GetMapping(path = "/content")
public ModelAndView getContent() {
ModelAndView mav = new ModelAndView();
mav.setViewName("content");
@ -3324,10 +3324,10 @@ Spring MVC also provides a mechanism for building links to controller methods. F
@@ -3324,10 +3324,10 @@ Spring MVC also provides a mechanism for building links to controller methods. F
[subs="verbatim,quotes"]
----
@Controller
@RequestMapping("/hotels/{hotel}")
@RequestMapping(path = "/hotels/{hotel}")
public class BookingController {
@GetMapping("/bookings/{booking}")
@GetMapping(path = "/bookings/{booking}")
public String getBooking(@PathVariable Long booking) {
// ...
@ -3418,10 +3418,10 @@ For example given:
@@ -3418,10 +3418,10 @@ For example given:
[source,java,indent=0]
[subs="verbatim,quotes"]
----
@RequestMapping("/people/{id}/addresses")
@RequestMapping(path = "/people/{id}/addresses")
public class PersonAddressController {
@RequestMapping("/{country}")
@RequestMapping(path = "/{country}")
public HttpEntity getAddress(@PathVariable String country) { ... }
}
----
@ -3792,9 +3792,9 @@ use `MultipartHttpServletRequest` or `MultipartFile` in the method parameters:
@@ -3792,9 +3792,9 @@ use `MultipartHttpServletRequest` or `MultipartFile` in the method parameters:
@Controller
public class FileUploadController {
@PostMapping("/form")
public String handleFormUpload(@RequestParam("name") String name,
@RequestParam("file") MultipartFile file) {
@PostMapping(path = "/form")
public String handleFormUpload(@RequestParam(name = "name") String name,