- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我是这个项目的新手,我尝试在本地计算机中运行它,并在 ubuntu 16.04LTS java api Spring 安全错误上收到此错误。似乎也没有什么问题。
我的安全配置
@Configuration
@EnableWebSecurity
@Profile("production")
@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private UserAuthorizationService userAuthorizationService;
@Autowired
private DataSource dataSource;
@Autowired
private ConfigurationParamsService configurationParamsService;
@Autowired
private AccessDeniedHandler oauthAccessDeniedHandler;
@Autowired
private AccessDecisionManager accessDecisionManager;
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/api/internal/v1/user/signup",
"/api/internal/v1/user/activate",
"/api/internal/v1/user/changePassword",
"/api/internal/v1/user/password/reset",
"/api/internal/v1/user/verifyPassword",
"/api/internal/v1/accounts/activate",
"/api/internal/v1/user/resend",
"/api/internal/v1/user/quick_signup");
}
@Override
public void configure(HttpSecurity http) throws Exception {
http.antMatcher("/api/internal/v1/user/login").csrf().disable()
.authorizeRequests()
.antMatchers("/api/internal/v1/user/login").permitAll();
http.exceptionHandling().authenticationEntryPoint(authenticationEntryPoint()).accessDeniedHandler(oauthAccessDeniedHandler).and().antMatcher("/api/v3/oauth2/auth**").csrf().disable()
.authorizeRequests().accessDecisionManager(accessDecisionManager).requestMatchers(new AntPathRequestMatcher("/api/v3/oauth2/auth")).authenticated();
http.rememberMe().rememberMeServices(rememberMeServices())
.tokenValiditySeconds(Integer.parseInt(configurationParamsService.getRememberMeTokenValiditySeconds()));
}
@Bean
@Scope(proxyMode = ScopedProxyMode.TARGET_CLASS)
public CustomEntryPoint authenticationEntryPoint() {
return new CustomEntryPoint();
}
@Bean
public RememberMeServices rememberMeServices() {
PersistentTokenBasedRememberMeServices rememberMeServices = new PersistentTokenBasedRememberMeServices(configurationParamsService.getRememberMeKey(), userAuthorizationService,
tokenRepository());
rememberMeServices.setAlwaysRemember(true);
rememberMeServices.setCookieName(configurationParamsService.getRememberMeCookieName());
rememberMeServices.setTokenValiditySeconds(Integer.parseInt(configurationParamsService.getRememberMeTokenValiditySeconds()));
return rememberMeServices;
}
@Bean
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
super.authenticationManagerBean();
List<AuthenticationProvider> providers = new ArrayList<>();
providers.add(rememberMeAuthenticationProvider());
return new ProviderManager(providers);
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userAuthorizationService);
auth.authenticationProvider(rememberMeAuthenticationProvider());
}
@Bean
public PersistentTokenRepository tokenRepository() {
JdbcTokenRepositoryImpl tokenRepository = new JdbcTokenRepositoryImpl();
tokenRepository.setDataSource(dataSource);
return tokenRepository;
}
@Bean
public RememberMeAuthenticationFilter rememberMeFilter() throws Exception {
RememberMeAuthenticationFilter rememberMeFilter = new RememberMeAuthenticationFilter(authenticationManagerBean(), rememberMeServices());
return rememberMeFilter;
}
@Bean
public AuthenticationProvider rememberMeAuthenticationProvider() {
return new RememberMeAuthenticationProvider(configurationParamsService.getRememberMeKey());
}
}
我的 Gradle 构建
buildscript {
ext {
springBootVersion = '1.4.0.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath("io.spring.gradle:dependency-management-plugin:0.5.1.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: "jacoco"
apply plugin: 'maven'
group = 'com.trackimo.server'
version = '0.0.0.1'
// Uses JDK 8
sourceCompatibility = 1.8
targetCompatibility = 1.8
// 1. Get dependencies from Maven local repository
// 2. Get dependencies from Maven central repository
repositories {
mavenLocal()
mavenCentral()
maven {
url 'http://repo.spring.io/snapshot'
}
}
ext {
logbackVersion = '1.1.3'
jsonDocVersion = '1.1.13'
hibernateVersion = '4.3.11.Final'
servletVersion = '3.1.0'
mandrillVersion = '0.0.5'
jodaTimeVersion = '2.8'
mokitoVersion = '1.9.5'
jsonPathVersion = '2.1.0'
hamcrestVersion = '1.3'
junitVersion = '4.11'
springOAuth2Version = '2.0.8.RELEASE'
dbUnitVersion = '2.5.1'
springtestdbunitVersion = '1.2.1'
springRedisDataVersion = '1.5.2.RELEASE'
redisClientVersion = '2.7.3'
quartzVersion = '2.2.1'
springContextVersion = '4.2.3.RELEASE'
commonsClientVersion = '3.1'
commonsUploadVersion = '1.3.1'
commonsIoVersion = '2.4'
kmlVersion = '2.2.1'
csvVersion = '1.2'
mailVersion = '1.4.7'
commonsLang3Version = '3.4'
cronparserVersion = '2.8'
brainTreePaymentsVersion = '2.52.0'
apachePioVersion = '3.13'
luceneVersion = '4.10.4'
ehcacheVersion = '2.6.11'
commonsValidator = '1.4.1'
airbrakeVersion = '2.2.8'
airbrakeLogbackVersion = '1.0.1'
}
configurations {
providedRuntime
}
dependencies {
// Amazon sqs dependency
compile "com.amazonaws:aws-java-sdk-sqs:1.10.27"
//spring configuration
compile "org.springframework:spring-context:${springContextVersion}"
compile "org.springframework:spring-context- support:${springContextVersion}"
compile('org.springframework.boot:spring-boot-starter-web')
//compile('org.springframework.boot:spring-boot-starter-data-elasticsearch')
compile('org.elasticsearch:elasticsearch:2.2.0')
compile('com.spatial4j:spatial4j:0.4.1')
compile "com.vividsolutions:jts:1.13"
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-security')
compile('org.hibernate:hibernate-validator')
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
runtime("mysql:mysql-connector-java")
runtime('com.h2database:h2')
//Social Dependencies
compile('org.springframework.social:spring-social-config')
compile('org.springframework.social:spring-social-core')
compile('org.springframework.social:spring-social-security')
compile('org.springframework.social:spring-social-web')
compile('org.springframework.social:spring-social-facebook:2.0.3.RELEASE')
compile('org.springframework.social:spring-social-google:1.0.0.RELEASE')
compile('org.springframework.social:spring-social-twitter:1.1.0.RELEASE')
compile('org.apache.httpcomponents:httpclient:4.3.6')
compile "redis.clients:jedis:${redisClientVersion}"
compile "org.springframework.data:spring-data-redis:${springRedisDataVersion}"
//spring security
compile "org.springframework.security.oauth:spring-security-oauth2:${springOAuth2Version}"
compile 'com.googlecode.json-simple:json-simple:1.1'
compile "org.hibernate:hibernate-ehcache:${hibernateVersion}"
compile "net.sf.ehcache:ehcache-core:${ehcacheVersion}"
compile "ch.qos.logback:logback-classic:${logbackVersion}"
compile "commons-httpclient:commons-httpclient:${commonsClientVersion}"
compile "commons-fileupload:commons-fileupload:${commonsUploadVersion}"
compile "commons-io:commons-io:${commonsIoVersion}"
compile "org.apache.commons:commons-lang3:${commonsLang3Version}"
compile "commons-validator:commons-validator:${commonsValidator}"
compile "com.mandrillapp.wrapper.lutung:lutung:${mandrillVersion}"
compile "org.quartz-scheduler:quartz:${quartzVersion}"
compile "org.quartz-scheduler:quartz-jobs:${quartzVersion}"
compile "javax.mail:mail:${mailVersion}"
compile "org.apache.commons:commons-csv:${csvVersion}"
compile "joda-time:joda-time:${jodaTimeVersion}"
//jsondoc configuration
compile "org.jsondoc:jsondoc-core:${jsonDocVersion}",
"org.jsondoc:jsondoc-springmvc:${jsonDocVersion}"
compile "org.dbunit:dbunit:${dbUnitVersion}"
compile "com.github.springtestdbunit:spring-test-dbunit:${springtestdbunitVersion}"
compile "de.micromata.jak:JavaAPIforKml:${kmlVersion}"
compile "com.braintreepayments.gateway:braintree-java:${brainTreePaymentsVersion}"
compile "com.twilio.sdk:twilio-java-sdk:3.4.5"
compile "org.apache.poi:poi:${apachePioVersion}"
compile 'com.paypal.sdk:adaptivepaymentssdk:2.8.117'
compile 'com.paypal.sdk:merchantsdk:2.14.117'
compile 'com.paypal.sdk:paypal-core:1.7.0'
compile 'com.paypal.sdk:rest-api-sdk:1.4.1'
compile 'org.projectlombok:lombok:1.16.6'
compile 'com.zaxxer:HikariCP:2.5.1'
runtime "io.airbrake:airbrake-java:${airbrakeVersion}"
compile "net.anthavio:airbrake-logback:${airbrakeLogbackVersion}"
testCompile("junit:junit:${junitVersion}") {
testCompile("org.springframework.boot:spring-boot-starter-test")
testCompile "com.jayway.jsonpath:json-path:${jsonPathVersion}"
"com.jayway.jsonpath:json-path-assert:${jsonPathVersion}"
testCompile "org.hamcrest:hamcrest-all:${hamcrestVersion}"
exclude(module: 'hamcrest-core')
}
testCompile "org.powermock:powermock-mockito-release-full:1.6.4"
// testCompile('org.powermock:powermock-module-junit4:1.6.4')
// testCompile('org.powermock:powermock-api-mockito:1.6.4' )
}
eclipse {
classpath {
containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')
containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8'
}
}
jar { baseName = "trackimo" }
task coverageReport(type: JacocoReport) {
executionData = files("$buildDir/covarageTest/jacocoTest.exec")
classDirectories = files("$buildDir/classes");
sourceDirectories = files("src");
reports {
xml.enabled false
csv.enabled false
html.destination "$buildDir/reports/covarageTest/jacocoHtml"
}
}
test {
jacoco {
append = true
destinationFile = file("$buildDir/covarageTest/jacocoTest.exec")
classDumpFile = file("$buildDir/covarageTest/classpathdumps")
}
finalizedBy tasks.coverageReport
}
task wrapper(type: Wrapper) { gradleVersion = '2.14' }
当我运行以下代码时,会导致以下错误
错误日志:
.19:42:21.368 [main] ERROR o.s.boot.SpringApplication - Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springSecurityFilterChain' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecur ityConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.servlet.Filter]: Factory method 'springSecurityFilterChain' threw exception; nested exception is org.springframework.security.config.annotation.AlreadyBuiltException: This object has already been built
at org.springframework.beans.factory.support.ConstructorResolver.instantiateU singFactoryMethod(ConstructorResolver.java:599) ~[spring-beans- 4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:296) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:838) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.SpringApplication.doRun(SpringApplication.java:347) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:295) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1112) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1101) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at com.trackimo.server.TrackimoServerApplication.main(TrackimoServerApplication.java:15) [main/:na]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.servlet.Filter]: Factory method 'springSecurityFilterChain' threw exception; nested exception is org.springframework.security.config.annotation.AlreadyBuiltException: This object has already been built
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
... 20 common frames omitted
Caused by: org.springframework.security.config.annotation.AlreadyBuiltException: This object has already been built
at org.springframework.security.config.annotation.AbstractSecurityBuilder.build(AbstractSecurityBuilder.java:44) ~[spring-security-config-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration.springSecurityFilterChain(WebSecurityConfiguration.java:105) ~[spring-security-config-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration$$EnhancerBySpringCGLIB$$9a87c1cf.CGLIB$springSecurityFilterChain$3(<generated>) ~[spring-security-config-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration$$EnhancerBySpringCGLIB$$9a87c1cf$$FastClassBySpringCGLIB$$5dcb6e03.invoke(<generated>) ~[spring-security-config-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:318) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.security.config.annotation.web.configuration.WebSecuri tyConfiguration$$EnhancerBySpringCGLIB$$9a87c1cf.springSecurityFilterChain (<generated>) ~[spring-security-config-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorIm pl.java:43) ~[na:1.8.0_121]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.inst antiate(SimpleInstantiationStrategy.java:162) ~[spring-beans- 4.2.3.RELEASE.jar:4.2.3.RELEASE]
... 21 common frames omitted
:run FAILED
最佳答案
以下重复配置导致了此问题:
http.antMatcher("/api/internal/v1/user/login").csrf().disable()
.authorizeRequests()
.antMatchers("/api/internal/v1/user/login").permitAll();
关于java - Spring安全配置: AlreadyBuiltException: This object has already been built,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41893985/
我正在使用 Kotlin 和 Dagger 2 开发一个 Android 项目。我有一个 NetworkModule它应该提供 Retrofit 的单例实例。我在其中定义了所有这些提供程序功能。 下面
我从 util/buildscripts/build.sh 构建 dojo 并包含我的自定义模块导致层文件(示例 dojo.js)仅包含文本“//>>built”。 最佳答案 这里讨论了问题并解决了问
这个问题在这里已经有了答案: How to unhide an overriden function? (1 个回答) 关闭 9 年前。 在我的 Matlab 路径上有一个自定义的 zeros 函数
我试图找到一个内置的几何平均值,但找不到。 (显然,在 shell 中工作时,内置函数不会为我节省任何时间,我也不怀疑准确性有任何差异;对于脚本,我尝试尽可能频繁地使用内置函数,其中(累积)性能提升通
我想知道在 keycloak (KL) 中是否可以分析身份验证日志(尝试次数、错误等),如果 KL 已经提供了这样做的东西,或者我必须构建它。欢迎提出任何建议。 谢谢尼古拉 最佳答案 Keycloak
我想知道在 keycloak (KL) 中是否可以分析身份验证日志(尝试次数、错误等),如果 KL 已经提供了这样做的东西,或者我必须构建它。欢迎提出任何建议。 谢谢尼古拉 最佳答案 Keycloak
据我所知,Python builtins 指的是那些包含在__builtins__ 中的异常和函数: >>> import builtins # import __builtin__ in Pyth
我想修改currency过滤以处理输入值中的自定义货币格式。 (例如,AUD 3.00 -> $3.00)。 一种选择是从头开始编写我自己的过滤器。然而,这似乎有很多重复,鉴于现有的过滤器很棒,我只需
我正在深入研究一些 C 内部结构,我从 clang 的 stddef.h 中找到了以下行(位于 /usr/lib/llvm-11/lib/clang/11.0 .0/include/): typede
这是一个由两部分组成的部分:首先,定义一个函数,distance_from_zero,带有一个参数(选择您喜欢的任何参数名称)。 其次,让该函数执行以下操作: 检查它接收到的输入的类型。如果类型为 i
我创建了一个接受 event 的函数对象并使用 .clientX 和 .clientY 属性做一些事情。基于我传递的是整个对象,而不仅仅是我将使用的属性,是否存在任何性能问题?这个对象是通过引用传递的
我目前正在从 ECMA 学习 JavaScript Manual ,我对内置对象的概念感到困惑。我知道像Function、Object、Math这样的对象是内置对象,你可以直接使用它们,例如Math
我想对我正在构建的小型应用程序使用潜在语义分析,但我不想自己构建矩阵。 (部分是因为我拥有的文档不会成为一个很好的培训集合,因为它们有点短且异构,部分是因为我刚买了一台新计算机,我发现安装线性代数之类
我是 C++ 的初学者,所以如果答案很明显,它可能就是我正在寻找的答案。我正在阅读 this thread 中的第二个回复并感到困惑。 #include #include int main() {
我需要用字符串构建一个对象属性但是我怎么能使用这个字符串的值作为属性名呢? var x = 'a'; var y = 'b'; var xy = x + y; var z = { xy: 's
我目前正在使用 java 中的 play 框架 2.2.6 开发一个应用程序。我的系统需要区分两个用户角色:管理员和用户。 到目前为止,我知道使用 Security.Authenticator 类来防
提问界面标记了许多“可能已经有您的答案的问题”,但我已尝试进行尽职调查以检查是否有任何人在问我在这里的确切内容。如果这是重复的,我深表歉意。 假设我有以下不正确的程序: extern void und
我需要在主屏幕上有相对缓慢移动的图像(有些像动态壁纸),我想知道,就 CPU 负载而言,Android 动画类是否适合这种情况? 我担心的是 android 动画以最高帧速率不断运行,有时它会连续几个
我想知道是否可以从 java.util.stream.Collectors 扩展内置的 Java Stream 收集器类,而不是从头开始构建自定义收集器,因此复制已经在该类中实现的代码。 例如:假设我
以下是我使用 Python 3.8.1(在 macOS Mojave,10.14.6 上,作为 以及其他一些平台上的 Python 3.7(或更旧的))。我是新来的 计算,不知道如何要求改进 语言,但
我是一名优秀的程序员,十分优秀!