Merge branch '5.1.x'
This commit is contained in:
@@ -1692,14 +1692,14 @@ you can use the `and`, `or`, and `not` keywords in place of `&&`, `||`, and `!`,
|
||||
respectively. For example, the previous pointcut can be better written as follows:
|
||||
|
||||
[source,xml,indent=0]
|
||||
[subs="verbatim,quotes"]
|
||||
[subs="verbatim"]
|
||||
----
|
||||
<aop:config>
|
||||
|
||||
<aop:aspect id="myAspect" ref="aBean">
|
||||
|
||||
<aop:pointcut id="businessService"
|
||||
expression="execution(* com.xyz.myapp.service.*.*(..)) **and** this(service)"/>
|
||||
expression="execution(* com.xyz.myapp.service.*.*(..)) and this(service)"/>
|
||||
|
||||
<aop:before pointcut-ref="businessService" method="monitor"/>
|
||||
|
||||
@@ -3122,7 +3122,7 @@ the following example:
|
||||
class="foo.StubEntitlementCalculationService"/>
|
||||
|
||||
<!-- this switches on the load-time weaving -->
|
||||
**<context:load-time-weaver/>**
|
||||
<context:load-time-weaver/>
|
||||
</beans>
|
||||
----
|
||||
|
||||
|
||||
@@ -810,7 +810,7 @@ use the `NamespaceHandlerSupport` class:
|
||||
public class MyNamespaceHandler extends NamespaceHandlerSupport {
|
||||
|
||||
public void init() {
|
||||
**registerBeanDefinitionParser("dateformat", new SimpleDateFormatBeanDefinitionParser());**
|
||||
registerBeanDefinitionParser("dateformat", new SimpleDateFormatBeanDefinitionParser());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2656,7 +2656,7 @@ to do so:
|
||||
[source,java,indent=0]
|
||||
[subs="verbatim,quotes"]
|
||||
----
|
||||
**@RequestScope**
|
||||
@RequestScope
|
||||
@Component
|
||||
public class LoginAction {
|
||||
// ...
|
||||
@@ -2692,7 +2692,7 @@ When using annotation-driven components or Java configuration, you can use the
|
||||
[source,java,indent=0]
|
||||
[subs="verbatim,quotes"]
|
||||
----
|
||||
**@SessionScope**
|
||||
@SessionScope
|
||||
@Component
|
||||
public class UserPreferences {
|
||||
// ...
|
||||
@@ -2727,7 +2727,7 @@ following example shows how to do so:
|
||||
[source,java,indent=0]
|
||||
[subs="verbatim,quotes"]
|
||||
----
|
||||
**@ApplicationScope**
|
||||
@ApplicationScope
|
||||
@Component
|
||||
public class AppPreferences {
|
||||
// ...
|
||||
@@ -4615,7 +4615,7 @@ primary `MovieCatalog`:
|
||||
public class MovieConfiguration {
|
||||
|
||||
@Bean
|
||||
**@Primary**
|
||||
@Primary
|
||||
public MovieCatalog firstMovieCatalog() { ... }
|
||||
|
||||
@Bean
|
||||
@@ -4656,7 +4656,7 @@ The corresponding bean definitions follow:
|
||||
|
||||
<context:annotation-config/>
|
||||
|
||||
<bean class="example.SimpleMovieCatalog" **primary="true"**>
|
||||
<bean class="example.SimpleMovieCatalog" primary="true">
|
||||
<!-- inject any dependencies required by this bean -->
|
||||
</bean>
|
||||
|
||||
@@ -4687,7 +4687,7 @@ shown in the following example:
|
||||
public class MovieRecommender {
|
||||
|
||||
@Autowired
|
||||
**@Qualifier("main")**
|
||||
@Qualifier("main")
|
||||
private MovieCatalog movieCatalog;
|
||||
|
||||
// ...
|
||||
@@ -4707,7 +4707,7 @@ method parameters, as shown in the following example:
|
||||
private CustomerPreferenceDao customerPreferenceDao;
|
||||
|
||||
@Autowired
|
||||
public void prepare(**@Qualifier("main")**MovieCatalog movieCatalog,
|
||||
public void prepare(@Qualifier("main") MovieCatalog movieCatalog,
|
||||
CustomerPreferenceDao customerPreferenceDao) {
|
||||
this.movieCatalog = movieCatalog;
|
||||
this.customerPreferenceDao = customerPreferenceDao;
|
||||
@@ -4823,7 +4823,7 @@ provide the `@Qualifier` annotation within your definition, as the following exa
|
||||
----
|
||||
@Target({ElementType.FIELD, ElementType.PARAMETER})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
**@Qualifier**
|
||||
@Qualifier
|
||||
public @interface Genre {
|
||||
|
||||
String value();
|
||||
@@ -4839,13 +4839,13 @@ following example shows:
|
||||
public class MovieRecommender {
|
||||
|
||||
@Autowired
|
||||
**@Genre("Action")**
|
||||
@Genre("Action")
|
||||
private MovieCatalog actionCatalog;
|
||||
|
||||
private MovieCatalog comedyCatalog;
|
||||
|
||||
@Autowired
|
||||
public void setComedyCatalog(**@Genre("Comedy")** MovieCatalog comedyCatalog) {
|
||||
public void setComedyCatalog(@Genre("Comedy") MovieCatalog comedyCatalog) {
|
||||
this.comedyCatalog = comedyCatalog;
|
||||
}
|
||||
|
||||
@@ -4875,12 +4875,12 @@ demonstrates both approaches:
|
||||
<context:annotation-config/>
|
||||
|
||||
<bean class="example.SimpleMovieCatalog">
|
||||
**<qualifier type="Genre" value="Action"/>**
|
||||
<qualifier type="Genre" value="Action"/>
|
||||
<!-- inject any dependencies required by this bean -->
|
||||
</bean>
|
||||
|
||||
<bean class="example.SimpleMovieCatalog">
|
||||
**<qualifier type="example.Genre" value="Comedy"/>**
|
||||
<qualifier type="example.Genre" value="Comedy"/>
|
||||
<!-- inject any dependencies required by this bean -->
|
||||
</bean>
|
||||
|
||||
@@ -5179,7 +5179,7 @@ named `movieFinder` injected into its setter method:
|
||||
|
||||
private MovieFinder movieFinder;
|
||||
|
||||
**@Resource**
|
||||
@Resource
|
||||
public void setMovieFinder(MovieFinder movieFinder) {
|
||||
this.movieFinder = movieFinder;
|
||||
}
|
||||
@@ -5381,7 +5381,7 @@ You can then use `@SessionScope` without declaring the `proxyMode` as follows:
|
||||
[subs="verbatim,quotes"]
|
||||
----
|
||||
@Service
|
||||
**@SessionScope**
|
||||
@SessionScope
|
||||
public class SessionScopedService {
|
||||
// ...
|
||||
}
|
||||
@@ -5393,7 +5393,7 @@ You can also override the value for the `proxyMode`, as the following example sh
|
||||
[subs="verbatim,quotes"]
|
||||
----
|
||||
@Service
|
||||
**@SessionScope(proxyMode = ScopedProxyMode.INTERFACES)**
|
||||
@SessionScope(proxyMode = ScopedProxyMode.INTERFACES)
|
||||
public class SessionScopedUserService implements UserService {
|
||||
// ...
|
||||
}
|
||||
@@ -5896,7 +5896,7 @@ technique:
|
||||
[subs="verbatim,quotes"]
|
||||
----
|
||||
@Component
|
||||
**@Qualifier("Action")**
|
||||
@Qualifier("Action")
|
||||
public class ActionMovieCatalog implements MovieCatalog {
|
||||
// ...
|
||||
}
|
||||
@@ -5906,7 +5906,7 @@ technique:
|
||||
[subs="verbatim,quotes"]
|
||||
----
|
||||
@Component
|
||||
**@Genre("Action")**
|
||||
@Genre("Action")
|
||||
public class ActionMovieCatalog implements MovieCatalog {
|
||||
// ...
|
||||
}
|
||||
@@ -5916,7 +5916,7 @@ technique:
|
||||
[subs="verbatim,quotes"]
|
||||
----
|
||||
@Component
|
||||
**@Offline**
|
||||
@Offline
|
||||
public class CachingMovieCatalog implements MovieCatalog {
|
||||
// ...
|
||||
}
|
||||
@@ -6782,7 +6782,7 @@ as the following example shows:
|
||||
public class MyConfiguration {
|
||||
|
||||
@Bean
|
||||
**@Scope("prototype")**
|
||||
@Scope("prototype")
|
||||
public Encryptor encryptor() {
|
||||
// ...
|
||||
}
|
||||
@@ -6808,7 +6808,7 @@ it resembles the following:
|
||||
----
|
||||
// an HTTP Session-scoped bean exposed as a proxy
|
||||
@Bean
|
||||
**@SessionScope**
|
||||
@SessionScope
|
||||
public UserPreferences userPreferences() {
|
||||
return new UserPreferences();
|
||||
}
|
||||
@@ -6883,7 +6883,7 @@ annotation, as the following example shows:
|
||||
public class AppConfig {
|
||||
|
||||
@Bean
|
||||
**@Description("Provides a basic example of a bean")**
|
||||
@Description("Provides a basic example of a bean")
|
||||
public Thing thing() {
|
||||
return new Thing();
|
||||
}
|
||||
@@ -7674,7 +7674,7 @@ can rewrite the `dataSource` configuration as follows:
|
||||
[subs="verbatim,quotes"]
|
||||
----
|
||||
@Configuration
|
||||
**@Profile("development")**
|
||||
@Profile("development")
|
||||
public class StandaloneDataConfig {
|
||||
|
||||
@Bean
|
||||
@@ -7692,7 +7692,7 @@ can rewrite the `dataSource` configuration as follows:
|
||||
[subs="verbatim,quotes"]
|
||||
----
|
||||
@Configuration
|
||||
**@Profile("production")**
|
||||
@Profile("production")
|
||||
public class JndiDataConfig {
|
||||
|
||||
@Bean(destroyMethod="")
|
||||
@@ -7731,7 +7731,7 @@ of creating a custom composed annotation. The following example defines a custom
|
||||
----
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
**@Profile("production")**
|
||||
@Profile("production")
|
||||
public @interface Production {
|
||||
}
|
||||
----
|
||||
@@ -7952,7 +7952,7 @@ following example:
|
||||
[subs="verbatim,quotes"]
|
||||
----
|
||||
@Configuration
|
||||
**@Profile("default")**
|
||||
@Profile("default")
|
||||
public class DefaultDataConfig {
|
||||
|
||||
@Bean
|
||||
@@ -8063,7 +8063,7 @@ a call to `testBean.getName()` returns `myTestBean`:
|
||||
[subs="verbatim,quotes"]
|
||||
----
|
||||
@Configuration
|
||||
**@PropertySource("classpath:/com/myco/app.properties")**
|
||||
@PropertySource("classpath:/com/myco/app.properties")
|
||||
public class AppConfig {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -678,7 +678,7 @@ implementation of an `initBinder(..)` method:
|
||||
|
||||
protected void initBinder(HttpServletRequest request,
|
||||
ServletRequestDataBinder binder) throws Exception {
|
||||
**this.customPropertyEditorRegistrar.registerCustomEditors(binder);**
|
||||
this.customPropertyEditorRegistrar.registerCustomEditors(binder);
|
||||
}
|
||||
|
||||
// other methods to do with registering a User
|
||||
|
||||
@@ -1039,7 +1039,7 @@ Consider the following class definition:
|
||||
[subs="verbatim,quotes"]
|
||||
----
|
||||
// the service class that we want to make transactional
|
||||
**@Transactional**
|
||||
@Transactional
|
||||
public class DefaultFooService implements FooService {
|
||||
|
||||
Foo getFoo(String fooName);
|
||||
@@ -1502,7 +1502,7 @@ The following code shows the simple profiling aspect discussed earlier:
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
// this method *is* the around advice
|
||||
// this method is the around advice
|
||||
public Object profile(ProceedingJoinPoint call) throws Throwable {
|
||||
Object returnValue;
|
||||
StopWatch clock = new StopWatch(getClass().getName());
|
||||
@@ -1757,7 +1757,7 @@ with an anonymous class, as follows:
|
||||
[source,java,indent=0]
|
||||
[subs="verbatim,quotes"]
|
||||
----
|
||||
transactionTemplate.execute(new **TransactionCallbackWithoutResult**() {
|
||||
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
|
||||
protected void doInTransactionWithoutResult(TransactionStatus status) {
|
||||
updateOperation1();
|
||||
updateOperation2();
|
||||
@@ -1778,7 +1778,7 @@ Code within the callback can roll the transaction back by calling the
|
||||
updateOperation1();
|
||||
updateOperation2();
|
||||
} catch (SomeBusinessException ex) {
|
||||
**status.setRollbackOnly();**
|
||||
status.setRollbackOnly();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -2505,7 +2505,7 @@ the setter for the `DataSource`. This leads to DAOs that resemble the following:
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
public void setDataSource(DataSource dataSource) {
|
||||
**this.jdbcTemplate = new JdbcTemplate(dataSource);**
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
// JDBC-backed implementations of the methods on the CorporateEventDao follow...
|
||||
@@ -4828,7 +4828,7 @@ errors in the SQL it executes from the scripts, as the following example shows:
|
||||
[source,xml,indent=0]
|
||||
[subs="verbatim,quotes"]
|
||||
----
|
||||
<jdbc:initialize-database data-source="dataSource" **ignore-failures="DROPS"**>
|
||||
<jdbc:initialize-database data-source="dataSource" ignore-failures="DROPS">
|
||||
<jdbc:script location="..."/>
|
||||
</jdbc:initialize-database>
|
||||
----
|
||||
|
||||
@@ -44,12 +44,12 @@ The following example shows how to use JNDI to look up a data source without the
|
||||
[source,xml,indent=0]
|
||||
[subs="verbatim,quotes"]
|
||||
----
|
||||
<bean id="**dataSource**" class="org.springframework.jndi.JndiObjectFactoryBean">
|
||||
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
|
||||
<property name="jndiName" value="jdbc/MyDataSource"/>
|
||||
</bean>
|
||||
<bean id="userDao" class="com.foo.JdbcUserDao">
|
||||
<!-- Spring will do the cast automatically (as usual) -->
|
||||
<property name="dataSource" ref="**dataSource**"/>
|
||||
<property name="dataSource" ref="dataSource"/>
|
||||
</bean>
|
||||
----
|
||||
|
||||
@@ -59,11 +59,11 @@ schema:
|
||||
[source,xml,indent=0]
|
||||
[subs="verbatim,quotes"]
|
||||
----
|
||||
<jee:jndi-lookup id="**dataSource**" jndi-name="jdbc/MyDataSource"/>
|
||||
<jee:jndi-lookup id="dataSource" jndi-name="jdbc/MyDataSource"/>
|
||||
|
||||
<bean id="userDao" class="com.foo.JdbcUserDao">
|
||||
<!-- Spring will do the cast automatically (as usual) -->
|
||||
<property name="dataSource" ref="**dataSource**"/>
|
||||
<property name="dataSource" ref="dataSource"/>
|
||||
</bean>
|
||||
----
|
||||
|
||||
|
||||
@@ -2027,7 +2027,7 @@ containers that ships with Spring (in this case, `DefaultMessageListenerContaine
|
||||
<bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
|
||||
<property name="connectionFactory" ref="connectionFactory"/>
|
||||
<property name="destination" ref="destination"/>
|
||||
**<property name="messageListener" ref="messageListener"/>**
|
||||
<property name="messageListener" ref="messageListener"/>
|
||||
</bean>
|
||||
----
|
||||
|
||||
@@ -2119,17 +2119,17 @@ POJO that we can make into an MDP through the following configuration:
|
||||
[subs="verbatim,quotes"]
|
||||
----
|
||||
<!-- this is the Message Driven POJO (MDP) -->
|
||||
**<bean id="messageListener" class="org.springframework.jms.listener.adapter.MessageListenerAdapter">
|
||||
<bean id="messageListener" class="org.springframework.jms.listener.adapter.MessageListenerAdapter">
|
||||
<constructor-arg>
|
||||
<bean class="jmsexample.DefaultMessageDelegate"/>
|
||||
</constructor-arg>
|
||||
</bean>**
|
||||
</bean>
|
||||
|
||||
<!-- and this is the message listener container... -->
|
||||
<bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
|
||||
<property name="connectionFactory" ref="connectionFactory"/>
|
||||
<property name="destination" ref="destination"/>
|
||||
**<property name="messageListener" ref="messageListener"/>**
|
||||
<property name="messageListener" ref="messageListener"/>
|
||||
</bean>
|
||||
----
|
||||
|
||||
@@ -2236,7 +2236,7 @@ Consider the following bean definition:
|
||||
<property name="connectionFactory" ref="connectionFactory"/>
|
||||
<property name="destination" ref="destination"/>
|
||||
<property name="messageListener" ref="messageListener"/>
|
||||
**<property name="sessionTransacted" value="true"/>**
|
||||
<property name="sessionTransacted" value="true"/>
|
||||
</bean>
|
||||
----
|
||||
|
||||
@@ -2674,7 +2674,7 @@ namespace elements, you need to reference the JMS schema, as the following examp
|
||||
xmlns:jms="http://www.springframework.org/schema/jms" <1>
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
**http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms.xsd**">
|
||||
http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms.xsd">
|
||||
|
||||
<!-- bean definitions here -->
|
||||
|
||||
@@ -6942,13 +6942,13 @@ do yourself a favor and read <<core.adoc#expressions, Spring Expression Language
|
||||
[source,java,indent=0]
|
||||
[subs="verbatim,quotes"]
|
||||
----
|
||||
@Cacheable(cacheNames="books", **key="#isbn"**)
|
||||
@Cacheable(cacheNames="books", key="#isbn")
|
||||
public Book findBook(ISBN isbn, boolean checkWarehouse, boolean includeUsed)
|
||||
|
||||
@Cacheable(cacheNames="books", **key="#isbn.rawNumber"**)
|
||||
@Cacheable(cacheNames="books", key="#isbn.rawNumber")
|
||||
public Book findBook(ISBN isbn, boolean checkWarehouse, boolean includeUsed)
|
||||
|
||||
@Cacheable(cacheNames="books", **key="T(someType).hash(#isbn)"**)
|
||||
@Cacheable(cacheNames="books", key="T(someType).hash(#isbn)")
|
||||
public Book findBook(ISBN isbn, boolean checkWarehouse, boolean includeUsed)
|
||||
----
|
||||
|
||||
@@ -6962,7 +6962,7 @@ so, specify the name of the `KeyGenerator` bean implementation to use, as the fo
|
||||
[source,java,indent=0]
|
||||
[subs="verbatim,quotes"]
|
||||
----
|
||||
@Cacheable(cacheNames="books", **keyGenerator="myKeyGenerator"**)
|
||||
@Cacheable(cacheNames="books", keyGenerator="myKeyGenerator")
|
||||
public Book findBook(ISBN isbn, boolean checkWarehouse, boolean includeUsed)
|
||||
----
|
||||
|
||||
@@ -7091,7 +7091,7 @@ supported wrapper, so the previous example can be rewritten as follows:
|
||||
[source,java,indent=0]
|
||||
[subs="verbatim,quotes"]
|
||||
----
|
||||
@Cacheable(cacheNames="book", condition="#name.length() < 32", **unless="#result?.hardback"**)
|
||||
@Cacheable(cacheNames="book", condition="#name.length() < 32", unless="#result?.hardback")
|
||||
public Optional<Book> findBook(String name)
|
||||
----
|
||||
|
||||
@@ -7572,11 +7572,11 @@ Spring's abstraction and the other using JCache:
|
||||
[source,java,indent=0]
|
||||
[subs="verbatim,quotes"]
|
||||
----
|
||||
@Cacheable(cacheNames="books", **key="#isbn"**)
|
||||
@Cacheable(cacheNames="books", key="#isbn")
|
||||
public Book findBook(ISBN isbn, boolean checkWarehouse, boolean includeUsed)
|
||||
|
||||
@CacheResult(cacheName="books")
|
||||
public Book findBook(**@CacheKey** ISBN isbn, boolean checkWarehouse, boolean includeUsed)
|
||||
public Book findBook(@CacheKey ISBN isbn, boolean checkWarehouse, boolean includeUsed)
|
||||
----
|
||||
|
||||
You can also specify the `CacheKeyResolver` on the operation, similar to how you can
|
||||
@@ -7593,8 +7593,8 @@ invoking the method again:
|
||||
[source,java,indent=0]
|
||||
[subs="verbatim,quotes"]
|
||||
----
|
||||
@CacheResult(cacheName="books", **exceptionCacheName="failures"**
|
||||
**cachedExceptions = InvalidIsbnNotFoundException.class**)
|
||||
@CacheResult(cacheName="books", exceptionCacheName="failures"
|
||||
cachedExceptions = InvalidIsbnNotFoundException.class)
|
||||
public Book findBook(ISBN isbn)
|
||||
----
|
||||
|
||||
|
||||
@@ -400,9 +400,9 @@ does not work:
|
||||
----
|
||||
<lang:groovy id="badMessenger"
|
||||
script-source="classpath:Messenger.groovy">
|
||||
<!-- this next constructor argument will *not* be injected into the GroovyMessenger -->
|
||||
<!-- this next constructor argument will not be injected into the GroovyMessenger -->
|
||||
<!-- in fact, this isn't even allowed according to the schema -->
|
||||
<constructor-arg value="This will *not* work" />
|
||||
<constructor-arg value="This will not work" />
|
||||
|
||||
<!-- only property values are injected into the dynamic-language-backed object -->
|
||||
<lang:property name="anotherMessage" value="Passed straight through to the dynamic-language-backed object" />
|
||||
|
||||
@@ -3234,11 +3234,11 @@ 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
|
||||
**@ContextConfiguration("repository-config.xml")**
|
||||
@ContextConfiguration("repository-config.xml")
|
||||
public class HibernateTitleRepositoryTests {
|
||||
|
||||
// this instance will be dependency injected by type
|
||||
**@Autowired**
|
||||
@Autowired
|
||||
private HibernateTitleRepository titleRepository;
|
||||
|
||||
@Test
|
||||
@@ -3257,13 +3257,13 @@ follows:
|
||||
----
|
||||
@RunWith(SpringRunner.class)
|
||||
// specifies the Spring configuration to load for this test fixture
|
||||
**@ContextConfiguration("repository-config.xml")**
|
||||
@ContextConfiguration("repository-config.xml")
|
||||
public class HibernateTitleRepositoryTests {
|
||||
|
||||
// this instance will be dependency injected by type
|
||||
private HibernateTitleRepository titleRepository;
|
||||
|
||||
**@Autowired**
|
||||
@Autowired
|
||||
public void setTitleRepository(HibernateTitleRepository titleRepository) {
|
||||
this.titleRepository = titleRepository;
|
||||
}
|
||||
@@ -3290,7 +3290,7 @@ shows this configuration:
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<!-- this bean will be injected into the HibernateTitleRepositoryTests class -->
|
||||
<bean id="**titleRepository**" class="**com.foo.repository.hibernate.HibernateTitleRepository**">
|
||||
<bean id="titleRepository" class="com.foo.repository.hibernate.HibernateTitleRepository">
|
||||
<property name="sessionFactory" ref="sessionFactory"/>
|
||||
</bean>
|
||||
|
||||
@@ -3317,8 +3317,8 @@ method in the superclass as well):
|
||||
|
||||
@Autowired
|
||||
@Override
|
||||
public void setDataSource(**@Qualifier("myDataSource")** DataSource dataSource) {
|
||||
**super**.setDataSource(dataSource);
|
||||
public void setDataSource(@Qualifier("myDataSource") DataSource dataSource) {
|
||||
super.setDataSource(dataSource);
|
||||
}
|
||||
|
||||
// ...
|
||||
@@ -3694,11 +3694,11 @@ following example shows the relevant annotations in bold:
|
||||
----
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration
|
||||
**@Transactional(transactionManager = "txMgr")**
|
||||
**@Commit**
|
||||
@Transactional(transactionManager = "txMgr")
|
||||
@Commit
|
||||
public class FictitiousTransactionalTest {
|
||||
|
||||
**@BeforeTransaction**
|
||||
@BeforeTransaction
|
||||
void verifyInitialDatabaseState() {
|
||||
// logic to verify the initial state before a transaction is started
|
||||
}
|
||||
@@ -3710,7 +3710,7 @@ following example shows the relevant annotations in bold:
|
||||
|
||||
@Test
|
||||
// overrides the class-level @Commit setting
|
||||
**@Rollback**
|
||||
@Rollback
|
||||
public void modifyDatabaseWithinTransaction() {
|
||||
// logic which uses the test data and modifies database state
|
||||
}
|
||||
@@ -3720,7 +3720,7 @@ following example shows the relevant annotations in bold:
|
||||
// execute "tear down" logic within the transaction
|
||||
}
|
||||
|
||||
**@AfterTransaction**
|
||||
@AfterTransaction
|
||||
void verifyFinalDatabaseState() {
|
||||
// logic to verify the final state after transaction has rolled back
|
||||
}
|
||||
|
||||
@@ -436,7 +436,7 @@ through the `syncBody` method, as the following example shows:
|
||||
|
||||
Mono<Void> result = client.post()
|
||||
.uri("/path", id)
|
||||
.syncBody(**builder.build()**)
|
||||
.syncBody(builder.build())
|
||||
.retrieve()
|
||||
.bodyToMono(Void.class);
|
||||
----
|
||||
|
||||
@@ -1315,7 +1315,7 @@ as the following example shows:
|
||||
[source,java,indent=0]
|
||||
[subs="verbatim,quotes"]
|
||||
----
|
||||
@PostMapping(path = "/pets", **consumes = "application/json"**)
|
||||
@PostMapping(path = "/pets", consumes = "application/json")
|
||||
public void addPet(@RequestBody Pet pet) {
|
||||
// ...
|
||||
}
|
||||
@@ -1342,7 +1342,7 @@ content types that a controller method produces, as the following example shows:
|
||||
[source,java,indent=0]
|
||||
[subs="verbatim,quotes"]
|
||||
----
|
||||
@GetMapping(path = "/pets/{petId}", **produces = "application/json;charset=UTF-8"**)
|
||||
@GetMapping(path = "/pets/{petId}", produces = "application/json;charset=UTF-8")
|
||||
@ResponseBody
|
||||
public Pet getPet(@PathVariable String petId) {
|
||||
// ...
|
||||
@@ -1970,7 +1970,7 @@ You can automatically apply validation after data binding by adding the
|
||||
[subs="verbatim,quotes"]
|
||||
----
|
||||
@PostMapping("/owners/{ownerId}/pets/{petId}/edit")
|
||||
public String processSubmit(**@Valid @ModelAttribute("pet") Pet pet**, BindingResult result) { <1>
|
||||
public String processSubmit(@Valid @ModelAttribute("pet") Pet pet, BindingResult result) { <1>
|
||||
if (result.hasErrors()) {
|
||||
return "petForm";
|
||||
}
|
||||
|
||||
@@ -2018,7 +2018,7 @@ The following example shows how to do so:
|
||||
// ...
|
||||
|
||||
@GetMapping
|
||||
public String setupForm(**@RequestParam("petId") int petId**, Model model) { <1>
|
||||
public String setupForm(@RequestParam("petId") int petId, Model model) { <1>
|
||||
Pet pet = this.clinic.loadPet(petId);
|
||||
model.addAttribute("pet", pet);
|
||||
return "petForm";
|
||||
@@ -2550,8 +2550,8 @@ probably want it deserialized from JSON (similar to `@RequestBody`). Use the
|
||||
[subs="verbatim,quotes"]
|
||||
----
|
||||
@PostMapping("/")
|
||||
public String handle(**@RequestPart("meta-data") MetaData metadata,
|
||||
@RequestPart("file-data") MultipartFile file**) {
|
||||
public String handle(@RequestPart("meta-data") MetaData metadata,
|
||||
@RequestPart("file-data") MultipartFile file) {
|
||||
// ...
|
||||
}
|
||||
----
|
||||
@@ -2567,8 +2567,8 @@ as the following example shows:
|
||||
[subs="verbatim,quotes"]
|
||||
----
|
||||
@PostMapping("/")
|
||||
public String handle(**@Valid** @RequestPart("meta-data") MetaData metadata,
|
||||
**BindingResult result**) {
|
||||
public String handle(@Valid @RequestPart("meta-data") MetaData metadata,
|
||||
BindingResult result) {
|
||||
// ...
|
||||
}
|
||||
----
|
||||
|
||||
@@ -1669,7 +1669,7 @@ The following example shows how to do so in Java configuration:
|
||||
|
||||
@Override
|
||||
public void configureMessageBroker(MessageBrokerRegistry registry) {
|
||||
registry.setPathMatcher(**new AntPathMatcher("."));**
|
||||
registry.setPathMatcher(new AntPathMatcher("."));
|
||||
registry.enableStompBrokerRelay("/queue", "/topic");
|
||||
registry.setApplicationDestinationPrefixes("/app");
|
||||
}
|
||||
@@ -1690,16 +1690,14 @@ The following example shows the XML configuration equivalent of the preceding ex
|
||||
http://www.springframework.org/schema/websocket
|
||||
http://www.springframework.org/schema/websocket/spring-websocket.xsd">
|
||||
|
||||
<websocket:message-broker application-destination-prefix="/app" path-matcher="**pathMatcher**">
|
||||
<websocket:message-broker application-destination-prefix="/app" path-matcher="pathMatcher">
|
||||
<websocket:stomp-endpoint path="/stomp"/>
|
||||
<websocket:stomp-broker-relay prefix="/topic,/queue" />
|
||||
</websocket:message-broker>
|
||||
|
||||
**
|
||||
<bean id="pathMatcher" class="org.springframework.util.AntPathMatcher">
|
||||
<constructor-arg index="0" value="."/>
|
||||
</bean>
|
||||
**
|
||||
|
||||
</beans>
|
||||
----
|
||||
|
||||
Reference in New Issue
Block a user