【发布时间】:2017-06-13 00:03:41
【问题描述】:
我有一个接口定义如下:
public interface MyService {
}
还有两个实现它的类:
@Service
@Profile("dev")
public class DevImplementation implements MyService {
}
和
@Service
@Profile("prod")
public class ProdImplementation implements MyService {
}
还有另一个服务试图使用它:
@Service
public MyClass {
@Autowired
MyService myservice;
}
问题是我在运行代码时收到NoSuchBeanException。它使用
mvn spring-boot:run -P dev
我做错了什么?
【问题讨论】:
标签: java spring autowired spring-profiles