请帮我从xml中创建一个spring config jJava文件。在xml bean中写成:
<bean id="SettingsControllerDS" class="org.mockito.Mockito" factory-method="mock">
<constructor-arg value="javax.sql.DataSource" />
</bean>
我尝试编写Java配置文件:
@Configuration
@ComponentScan(basePackages = {"XXXXXXXXXX"})
public class SpringBeanTestApplicationContext {
@Bean(name = "SettingsControllerDS")
public DataSource dataSource() { !!! ???????? !!!! }
}
答案 0 :(得分:1)
以下配置类将生成DataSource
的模拟实例:
@Configuration
public class SpringBeanTestApplicationContext {
@Bean(name = "SettingsControllerDS")
public DataSource dataSource() {
return Mockito.mock(DataSource.class);
}
}