springboot **Controller Autowired required a single bean, but 2 were found

来源:互联网 发布:我友网络 编辑:程序博客网 时间:2024/06/06 15:35
package com.lee;import ch.qos.logback.core.net.SyslogOutputStream;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.beans.factory.annotation.Qualifier;import org.springframework.boot.context.properties.EnableConfigurationProperties;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;@RestControllerpublic class SystemController {    @Autowired    @Qualifier("userVo")//加上这个,或者在实体类前面加上@primary的标签就不会报 SystemController Autowired  required a single bean, but 2 were found    UserVo user;    @RequestMapping("/index")    public String toIndex(){        return user.toString();    }    @Autowired    MyConfigVo myconfig;    @RequestMapping("/myconfig")    public String toMyConfig(){        return myconfig.toString();    }}

阅读全文
0 0
原创粉丝点击