public static void main(String[] args) { String iniResourcePath = "classpath:shiro.ini"; Factory<SecurityManager> factory = new IniSecurityManagerFactory(iniResourcePath); SecurityManager securityManager = factory.getInstance(); SecurityUtils.setSecurityManager(securityManager); Subject subject = SecurityUtils.getSubject(); UsernamePasswordToken token = new UsernamePasswordToken("zhangsan", "123456"); try { subject.login(token); System.out.println("登录成功"); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); System.out.println("登录失败"); } }