请帮我从xml制作一个spring配置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() { !!! ???????? !!!! }
}
以下配置类将生成DataSource
的模拟实例:
@Configuration
public class SpringBeanTestApplicationContext {
@Bean(name = "SettingsControllerDS")
public DataSource dataSource() {
return Mockito.mock(DataSource.class);
}
}