spring中配置 <context:component-scan base-package="com." />对服务自动扫描
public interface UserService {}
@Service("userService")
public class UserServiceImpl implements UserService {}
启动报错,
Annotation-specified bean name 'userService' for bean class [com.test.service.UserService] conflicts with existing
提示userservice重名,改为@Service后启动正常。
或者改spring中配置 <context:component-scan base-package="com...impl.*" /> 也能解决问题。
是不是spring对每个扫描过的文件都创建个bean名称呢