错误描述:conflicts with existing, non-compatible bean definition of same name and class 看错误描述是相同的类名冲突,它自己不会分辨包,我们可以自己加注解来区分他们
import org.springframework.stereotype.Component; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @Controller @RequestMapping("/admin") @Component("AdminLogin")//同名类需要写Component来区分 public class LoginController { @RequestMapping("")//根路由需要写空Mapping public String Login() { return "/admin/login/index"; } }
import org.springframework.stereotype.Component; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @Controller @RequestMapping("/agent") @Component("AgentLogin") public class LoginController { @RequestMapping("") public String Login() { return "/agent/login/index"; } }