spring5.1.5使用的jackson依赖版本

原先使用2.8.8版本的jackson结果控制台报错:

java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.exc.InvalidDefinitionException

原因是版本不匹配

使用2.9.8版本的jackson则问题解决

spring5要使用jackson 2.9.X的版本,低于会报错版本不匹配

转载于:https://www.cnblogs.com/zaks/p/11411858.html

Spring Security是一个强大的安全框架,可以帮助我们实现身份验证、授权、记住我和注销等功能。 下面是使用Spring Security的基本步骤: 1. 引入Spring Security依赖 在项目的pom.xml文件中,添加Spring Security的依赖。例如: ```xml <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-web</artifactId> <version>5.1.5.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-config</artifactId> <version>5.1.5.RELEASE</version> </dependency> ``` 2. 配置Spring Security 在Spring的配置文件中,配置Spring Security的安全策略。例如: ```xml <http auto-config="true"> <intercept-url pattern="/admin/**" access="ROLE_ADMIN" /> <form-login /> </http> <authentication-manager> <authentication-provider> <user-service> <user name="admin" password="admin" authorities="ROLE_ADMIN" /> <user name="user" password="user" authorities="ROLE_USER" /> </user-service> </authentication-provider> </authentication-manager> ``` 上面的配置定义了对`/admin/**`路径下的请求进行身份验证,只有拥有`ROLE_ADMIN`权限的用户才能访问。 3. 在代码中使用Spring Security 在代码中,可以使用Spring Security提供的API来进行身份验证和授权操作。例如: ```java @Autowired private AuthenticationManager authenticationManager; public void login(String username, String password) { Authentication authentication = authenticationManager.authenticate( new UsernamePasswordAuthenticationToken(username, password)); SecurityContextHolder.getContext().setAuthentication(authentication); } ``` 上面的代码中,使用了`AuthenticationManager`接口来进行身份验证,验证通过后,将`Authentication`对象保存到`SecurityContextHolder`中。 总的来说,使用Spring Security可以让我们更方便地实现应用程序的安全策略。通过配置和使用Spring Security提供的API,我们可以快速地实现身份验证、授权等功能,从而保护我们的应用程序的安全。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值