应该是什么价值:
compileSdkVersion
targetSdkVersion
我已经下载并安装了Android P Developer Preview SDK,系统映像和构建工具。
我试过" 28"但是它显示了这个错误:
答案 0 :(得分:12)
使用P预览:
@Configuration
@EnableWebSecurity
@Order(1)
public class SecurityJavaConfig extends WebSecurityConfigurerAdapter {
@Value("${yourapp.http.auth-token-header-name}")
private String principalRequestHeader;
@Value("${yourapp.http.auth-token}")
private String principalRequestValue;
@Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
APIKeyAuthFilter filter = new APIKeyAuthFilter(principalRequestHeader);
filter.setAuthenticationManager(new AuthenticationManager() {
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
String principal = (String) authentication.getPrincipal();
if (!principalRequestValue.equals(principal))
{
throw new BadCredentialsException("The API key was not found or not the expected value.");
}
authentication.setAuthenticated(true);
return authentication;
}
});
httpSecurity.
antMatcher("/api/**").
csrf().disable().
sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).
and().
addFilter(filter).authorizeRequests().anyRequest().authenticated();
}
答案 1 :(得分:6)
targetSdkVersion 'P'
和
gsub
答案 2 :(得分:0)
compileSdkVersion 'android-P'
与
targetSdkVersion 28
为我工作!