Fixed whitespace and added private modifiers to @Value-annotated fields in the @Configuration example
This commit is contained in:
parent
8aface8e5d
commit
c78f9d14fa
|
|
@ -314,22 +314,22 @@ public class RewardsTestDatabase {
|
|||
<para>Here is an example of a Java class providing basic configuration
|
||||
using the new JavaConfig features: <programlisting language="java">@Configuration
|
||||
public class AppConfig{
|
||||
@Value("#{jdbcProperties.url}") String jdbcUrl;
|
||||
@Value("#{jdbcProperties.username}") String username;
|
||||
@Value("#{jdbcProperties.password}") String password;
|
||||
private @Value("#{jdbcProperties.url}") String jdbcUrl;
|
||||
private @Value("#{jdbcProperties.username}") String username;
|
||||
private @Value("#{jdbcProperties.password}") String password;
|
||||
|
||||
@Bean
|
||||
public FooServicefooService() {
|
||||
public FooService fooService() {
|
||||
return new FooServiceImpl(fooRepository());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public FooRepositoryfooRepository() {
|
||||
public FooRepository fooRepository() {
|
||||
return new HibernateFooRepository(sessionFactory());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SessionFactorysessionFactory() {
|
||||
public SessionFactory sessionFactory() {
|
||||
// wire up a session factory using
|
||||
// AnnotationSessionFactoryBean
|
||||
asFactoryBean.setDataSource(dataSource());
|
||||
|
|
@ -337,9 +337,8 @@ public class AppConfig{
|
|||
}
|
||||
|
||||
@Bean
|
||||
public DataSourcedataSource() {
|
||||
return new DriverManagerDataSource(jdbcUrl,
|
||||
username, password);
|
||||
public DataSource dataSource() {
|
||||
return new DriverManagerDataSource(jdbcUrl, username, password);
|
||||
}
|
||||
}
|
||||
</programlisting> To get this to work you need to add the following component
|
||||
|
|
|
|||
Loading…
Reference in New Issue