问答详情
源自:3-1 Shiro认证

为什么会出现这个问题呢,请大神们帮我解答,求助

public class ShiroTest {
    SimpleAccountRealm simpleAccountRealm =new SimpleAccountRealm();
    @Before
    public void addUser(){
        simpleAccountRealm.addAccount("mark","123456");
    }

    @Test
    public void  testAuthentication(){



        //构建SecurityManager环境
        DefaultSecurityManager defaultSecurityManager =new DefaultSecurityManager();
        defaultSecurityManager.setRealm(simpleAccountRealm);

        //主动提交认证请求
        SecurityUtils.setSecurityManager(defaultSecurityManager);
        Subject subject = SecurityUtils.getSubject();


        UsernamePasswordToken usernamePasswordToken = new UsernamePasswordToken("mark","123456");
        subject.login(usernamePasswordToken);



    }
}


提问者:qq_迷途小书童_3 2018-12-24 14:35

个回答

  • qq_迷途小书童_3
    2018-12-24 14:53:59

    我这么写 有问题么,但是 编译过后,后台出现问题https://img4.mukewang.com/5c208279000102b125601600.jpg

    能帮我解决一下么