|
|
|
@ -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 |
|
|
|
|