我从5.2.10升级了Spring Security依赖项。释放至5.6.0,Spring防尘套从2.1.18开始。发布至2.4.11。升级后,所有使用MockMvc的控制器测试都会失败,堆栈跟踪如下。非常感谢您的帮助。
Java语言lang.IllegalStateException:无法展开代理对象
at org.springframework.test.util.AopTestUtils.getUltimateTargetObject(AopTestUtils.java:97)
at org.springframework.boot.test.mock.mockito.SpringBootMockResolver.resolve(SpringBootMockResolver.java:35)
at org.mockito.internal.util.MockUtil.resolve(MockUtil.java:118)
at org.mockito.internal.util.MockUtil.isMock(MockUtil.java:108)
at org.mockito.internal.util.DefaultMockingDetails.isMock(DefaultMockingDetails.java:32)
at org.springframework.boot.test.mock.mockito.MockReset.get(MockReset.java:106)
at org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener.resetMocks(ResetMocksTestExecutionListener.java:82)
at org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener.resetMocks(ResetMocksTestExecutionListener.java:70)
at org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener.beforeTestMethod(ResetMocksTestExecutionListener.java:57)
at org.springframework.test.context.TestContextManager.beforeTestMethod(TestContextManager.java:293)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
原因:tils.getBatchConfigurationException:tils.java:90MetaDataAccessException:无法获取连接提取元数据;嵌套异常org.springframework.jdbc.support.CannotGetJdbcConnectionException:未能获取JDBC连接:DataSource从getConnection()返回null:javax.sql.DataSource#0 bean在org.springframework.batch.core.configuration.annotation.DefaultBatchConfigurer.initialize(DefaultBatchConfigurer.java:119)在org.springframework.batch.core.configuration.annotation.AbstractBatchConfiguration.getConfigrer(AbstractBatchConfiguration.java:118)在org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration.initialize(SimpleBatchConfiguration.java:115)在org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration$Re0014 ceTargetSource.create对象(SimpleBatchConfiguration.java:143)在org.springframework.aop.target.AbstractLazyCreationTargetS目标ource.get(AbstractLazyCreationTargetSource.java:88)在org.springframework.test.util.AopTestUorg.springframework.batch.core.configuration.UltimateTargetObject(AopTestUorg.springframework.jdbc.support.)...30更多原因:org.springframework.jdbc.MetaDataAccessException:无法获取提取元数据的连接;嵌套JobRepositoryFactoryBean. After属性集(JobRepositoryFactoryBean. java: 183)在org. springframework. batch. core.配置.注释。DefaultBatchConfacrer. createJobRepository(DefaultBatchConfigrer. java: 134)在org. springframework. batch. core.配置.注释。DefaultBatchConfirer.初始化(DefaultBatchConfirer. java: 113)...35更多由以下原因引起:org. springframe. jdbc。无法获取JdbcConnectionException:无法获取JDBC连接:DataSource从getConnection()返回null:javax. sql。DataSource#0 bean在org. springframe. jdbc. datasource。DataSourceUtils. getConnection(DataSourceUtils. java:
Java语言lang.IllegalStateException:无法展开代理对象
at org.springframework.test.util.AopTestUtils.getUltimateTargetObject(AopTestUtils.java:97)
at org.springframework.boot.test.mock.mockito.SpringBootMockResolver.resolve(SpringBootMockResolver.java:35)
at org.mockito.internal.util.MockUtil.resolve(MockUtil.java:118)
at org.mockito.internal.util.MockUtil.isMock(MockUtil.java:108)
at org.mockito.internal.util.DefaultMockingDetails.isMock(DefaultMockingDetails.java:32)
at org.springframework.boot.test.mock.mockito.MockReset.get(MockReset.java:106)
at org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener.resetMocks(ResetMocksTestExecutionListener.java:82)
at org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener.resetMocks(ResetMocksTestExecutionListener.java:70)
at org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener.afterTestMethod(ResetMocksTestExecutionListener.java:64)
at org.springframework.test.context.TestContextManager.afterTestMethod(TestContextManager.java:445)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:94)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
原因:组织。springframework。一批果心配置BatchConfigurationException:组织。springframework。jdbc。支持MetaDataAccessException:无法获取用于提取元数据的连接;嵌套异常为org。springframework。jdbc。CannotGetJdbcConnectionException:无法获取JDBC连接:数据源从getConnection()返回null:javax。sql。组织上的DataSource#0 bean。springframework。一批果心配置注释。DefaultBatchConfigurer。在组织中初始化(DefaultBatchConfigurer.java:119)。springframework。一批果心配置注释。AbstractBatchConfiguration。位于org的getConfigurer(AbstractBatchConfiguration.java:118)。springframework。一批果心配置注释。SimpleBatchConfiguration。在组织中初始化(SimpleBatchConfiguration.java:115)。springframework。一批果心配置注释。SimpleBatchConfiguration$ReferenceTargetSource。位于org的createObject(SimpleBatchConfiguration.java:143)。springframework。aop。目标AbstractLazyCreationTargetSource。getTarget(AbstractLazyCreationTargetSource.java:88)位于org。springframework。测验util。AopTestUtils。getUltimateTargetObject(AopTestUtils.java:90)。。。29更多原因:组织。springframework。jdbc。支持MetaDataAccessException:无法获取用于提取元数据的连接;嵌套异常为org。springframework。jdbc。CannotGetJdbcConnectionException:无法获取JDBC连接:DataSource从getConnection()返回null:javax。sql。组织上的DataSource#0 bean。springframework。jdbc。支持JdbcUtils。org上的extractDatabaseMetaData(JdbcUtils.java:363)。springframework。jdbc。支持JdbcUtils。org上的extractDatabaseMetaData(JdbcUtils.java:395)。springframework。一批支持数据库类型。org上的fromMetaData(DatabaseType.java:102)。springframework。一批果心存储库。支持JobRepositoryFactoryBean。位于org的afterPropertiesSet(JobRepositoryFactoryBean.java:183)。springframework。一批果心配置注释。DefaultBatchConfigurer。位于org的createJobRepository(DefaultBatchConfigurer.java:134)。springframework。一批果心配置注释。DefaultBatchConfigurer。初始化(DefaultBatchConfigurer.java:113)。。。34更多原因:组织。springframework。jdbc。CannotGetJdbcConnectionException:无法获取JDBC连接:DataSource从getConnection()返回null:javax。sql。组织上的DataSource#0 bean。springframework。jdbc。数据源。数据源工具。位于org的getConnection(DataSourceUtils.java:85)。springframework。jdbc。支持JdbcUtils。extractDatabaseMetaData(JdbcUtils.java:337)。。。39更多
你没有看到整个stacktrace和根本原因,所以基本上你还没有真正的原因。
这通常是连接字符串的问题,例如您缺少有关时区的某些信息或不允许检索密钥...检查以下其他答案:
我正在测试家庭控制器 我使用spring security作为用户名“user”,默认情况下作为密码进行测试,但@PreAuthorize不起作用 的结果 预期结果: 实际结果: 我错过了什么吗?
我最近刚刚将团队的一个Spring Boot应用程序从2.1.3版升级到2.3.0版,并将Hibernate版本从5.3.6.final升级到5.4.15.final。 一切都很好,但是现在当应用程序在服务器上启动时,启动需要800-900秒(大约15分钟),而以前只需要30秒。 需要注意的是,当在localhost上运行2.1.3和2.3.0时,应用程序的启动是相同的,大约为12-15秒。 只有
在将我们的Spring云微服务(打包为Docker镜像)部署到AWS之前,我们在本地针对LocalStack进行测试。因此,我们在自动配置的代码库中定义了如下bean: 使用Spring Boot 2.3.5。RELEASE、Spring Cloud Hoxton。SR4和Spring Cloud Stream Binder Kinesis 2.0.1。RELEASE,我们能够针对LocalSta
你好,我是Spring和Spring保安新来的。目前我正在Spring开发rest api。根据spring提供rest API。rest api是无状态的,所以我们不能创建到rest api的会话。因为它是一个无状态的,如果我们这样做,那么它是违反rest设计的。所以我的问题是,在REST中,我们是不是可以永远保持服务器端用户的状态?我们可以维护它的客户端吗??怎么做??在spring basi
我想知道我应该如何为我的测试验证用户?现在,我将编写的所有测试都将失败,因为endpoint需要授权。
我正在尝试使用类中定义的自定义安全设置来测试: 是否可以使用类中定义的设置?