spring-test-dbunit 相关问题


如何在spring-boot web客户端发送请求体?

我在 Spring Boot Web 客户端发送请求正文时遇到一些问题。尝试发送如下所示的正文: val 主体 = "{ ” + "\"电子邮件\":\"[email protected]\", ” + “\”id\“:...


Spring boot + slf4j + log4j + 类 org.apache.logging.slf4j.SLF4JLoggerContext 无法转换为类

我有Spring boot 2.3.1 pom.xml 我有Spring boot 2.3.1 pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.3.1.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>logger</groupId> <artifactId>logger</artifactId> <version>0.0.1-SNAPSHOT</version> <name>logger</name> <description>Demo project for Spring Boot</description> <properties> <java.version>11</java.version> <lombok.version>1.18.12</lombok.version> <log4j.version>1.2.17</log4j.version> <slf4j.version>1.7.30</slf4j.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion> <artifactId>logback-classic</artifactId> <groupId>ch.qos.logback</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>${lombok.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>${slf4j.version}</version> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>${log4j.version}</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project> 班级 @Slf4j @SpringBootApplication public class LoggerApplication { public static void main(String[] args) { log.info("++++++++++++++++++++++++TEST+++++++++++++++++++++++++++++"); SpringApplication.run(LoggerApplication.class, args); } } 应用程序.属性 logging.config=classpath:log4j.properties log4j.properties log4j.rootLogger=INFO, console log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console.Target=System.out log4j.appender.console.layout=org.apache.log4j.PatternLayout log4j.appender.console.layout.conversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p - %m%n 我尝试寻找解决方案,查看论坛上的类似主题,尝试各种排除依赖项的选项。 线程“main”中的异常 java.lang.ClassCastException:类 org.apache.logging.slf4j.SLF4JLoggerContext 无法转换为类 org.apache.logging.log4j.core.LoggerContext (org.apache.logging.slf4j.SLF4JLoggerContext 和 org.apache.logging.log4j.core.LoggerContext 位于未命名模块中 加载器“应用程序”)位于 我还尝试排除一些依赖项 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion> <artifactId>logback-classic</artifactId> <groupId>ch.qos.logback</groupId> </exclusion> <exclusion> <groupId>log4j</groupId> <artifactId>*</artifactId> </exclusion> <exclusion> <groupId>org.slf4j</groupId> <artifactId>*</artifactId> </exclusion> <exclusion> <groupId>org.apache.logging.log4j</groupId> <artifactId>*</artifactId> </exclusion> </exclusions> </dependency> 但又出现错误,但现在无法再格式化日志了。 2021-01-13 19:12:15,881 信息 - ++++++++++++++++++++++++测试+++++++++++++++++++++++++++++++ 错误 StatusLogger 无法识别的格式说明符 [d] 错误 StatusLogger 无法识别的转换说明符 [d] 从转换模式中的位置 16 开始。 错误 StatusLogger 无法识别的格式说明符 [线程] 错误 StatusLogger 无法识别的转换说明符 [线程] 从转换模式中的位置 25 开始。 错误 StatusLogger 无法识别的格式说明符 [级别] 错误 StatusLogger 无法识别的转换说明符 [level] 从转换模式中的位置 35 开始。 ... 错误 StatusLogger 无法识别的格式说明符 [n] 错误 StatusLogger 无法识别的转换说明符 [n] 从转换模式中的位置 56 开始。 警告:不支持 sun.reflect.Reflection.getCallerClass。这会影响性能。 任何人都可以有任何想法如何解决它吗? 我找到了解决这个问题的方法。事实证明,问题出在其中一个私有库(elastik 的附加程序)的冲突上。 我执行了命令: mvn dependency:tree 然后找到传递依赖项,并将它们排除在所有类的路径上,以排除日志记录所需的库冲突。 pom.xml <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion> <artifactId>logback-classic</artifactId> <groupId>ch.qos.logback</groupId> </exclusion> <exclusion> <artifactId>log4j-to-slf4j</artifactId> <groupId>org.apache.logging.log4j</groupId> </exclusion> </exclusions> </dependency> <dependency> <artifactId>springfox-boot-starter</artifactId> <groupId>io.springfox</groupId> <version>3.0.0</version> <exclusions> <exclusion> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>${lombok.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>${log4j.version}</version> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> <version>${version.log4j.core}</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>${slf4j.version}</version> </dependency>


如何使用 .NET TEST EXPLORER 在 VS Code 中运行 NUnit 测试

我想从 .NET TEST EXPLORER 运行单元测试,而不是命令行。我可以在导航到单元测试目录并执行 dotnet test 时运行测试。 但选择 .NET TEST EXPLORER...


闪亮的server.R无法读取全局变量

./app 中的两个文件 ui.R 图书馆(闪亮) 一个<- 1 ui <- fluidPage( textOutput("test") ) server.R server <- function(input, output) { output$test <- renderText({ a ...


php 使用函数更改函数外部变量的值

我试图在使用函数时更改函数外部声明的变量的值 我试图更改在使用函数时声明的变量的值 <?php $test = 1; function addtest() { $test = $test + 1; } addtest(); echo $test; ?> 但似乎不能。只有在函数中声明为参数的变量才有效。有这方面的技术吗?预先感谢 将函数内部的变量更改为全局变量 - function addtest() { global $test; $test = $test + 1; } 使用全局变量有很多注意事项 - 从长远来看,您的代码将更难维护,因为全局变量可能会对未来的计算产生不良影响,您可能不知道如何操纵变量。 如果重构代码并且函数消失,这将是有害的,因为 $test 的每个实例都与代码紧密耦合。 这里有一个轻微的改进,不需要 global - $test = 1; function addtest($variable) { $newValue = $variable + 1; return $newValue; } echo $test; // 1 $foo = addtest($test); echo $foo; // 2 现在您不必使用全局变量,并且可以根据自己的喜好操作 $test,同时将新值分配给另一个变量。 不确定这是否是一个人为的示例,但在这种情况下(与大多数情况一样),使用global将是极其糟糕的形式。为什么不直接返回结果并分配返回值呢? $test = 1; function increment($val) { return $val + 1; } $test = increment($test); echo $test; 这样,如果您需要增加除 $test 之外的 任何其他 变量,您就已经完成了。 如果您需要更改多个值并返回它们,您可以返回一个数组并使用 PHP 的 list 轻松提取内容: function incrementMany($val1, $val2) { return array( $val1 + 1, $val2 + 1); } $test1 = 1; $test2 = 2; list($test1, $test2) = incrementMany($test1, $test2); echo $test1 . ', ' . $test2; 您还可以使用 func_get_args 接受动态数量的参数并返回动态数量的结果。 使用 global 关键字。 <?php $test = 1; function addtest() { global $test; $test = $test + 1; } addtest(); echo $test; // 2 ?> 也许你可以试试这个。 <?php function addTest(&$val){ # Add this & and val will update var who call in from outside $val += 1 ; } $test = 1; addTest($test); echo $test; // 2 $anyVar = 5; addTest($anyVar); echo $anyVar; // 6


将 Spring Security 5 迁移到 Spring Security 6 HttpSecurity 问题

Spring Security 6 中以下代码应该替代什么? http .authorizeRequests() .requestMatchers("/hub/**").access("hasPermission('SOME_LAYER', '')")...


Spring Boot 版本与 Java 11 兼容

大家好,目前我正计划将具有 spring 版本 4.0.6 和 java 8 的独立 spring 应用程序迁移到具有 java 11 的 Spring boot 应用程序。所以,继续使用 spring boot


指定psql连接的默认数据库?

在使用psql时,我想更改初始数据库连接。 我有一个名为“test”的数据库作为初始连接。 从命令行运行 psql 时,我的提示符为 test=# 之后


grpc-spring-boot-starter - 如果我将 spring-boot-starter-jdbc 添加到依赖项中,netty 服务器不会启动

我开始用spring boot测试grpc,我使用net.devh中提供的GrpcService:grpc-spring-boot-starter(https://yidongnan.github.io/grpc-spring-boot-起动器/en/)。 它隔离效果很好...


写入通道的随机结果(Go)

我有以下代码: 函数 writeToClosedBufferedChannel() { ch := make(chan int, 2) ch <- 10 ch <- 20 go func() { fmt.Println("test") ch <- ...


如何在Spring Boot 3和Spring Framework 6中注册拦截器

我正在使用 Spring Boot 3.1.0-SNAPSHOT 构建后端,它使用 Spring Framework 6x。 拦截器: @Slf4j 公共类 MyInterceptor 实现 HandlerInterceptor { @覆盖 公众嘘声...


使用Pytest时将主数据库更改为Test

帮我解决问题 这是我的设置.py: 数据库= { “默认”: { "ENGINE": "django.db.backends.mysql", “名称”:ENV.MYSQL_DSN....


Jaxb2Marshaller 与 Spring boot 3+ 和 Jaxb 4 兼容吗?

我正在将我的项目从 Spring Boot 2.7 升级到 Spring Boot 3.1。在这个项目中仍然使用 SOAP,因此我们依赖 Jaxb 和 spring WS。 我正在使用 com.helger.maven 生成 Java 类:


Spring @Transactional 迁移到 Spring 5 后不起作用

我最近将应用程序从带有 AspectJ 1.8.10 的 Spring 4.3.x 和 JDK 8 升级到带有 Spring 5.3.x 和 AspectJ 1.9.20.1 的 JDK 17,并且事务注释似乎不起作用 在应用中...


bean“mvcHandlerMappingIntrospectorRequestTransformer”无法注册。具有该名称的 bean 已被定义并覆盖 i

环境:Spring Boot 3.2.1、JDK 21、GraalVM、Spring Native、Spring Security。错误 微软Windows [版本10.0.22631.2861] (c) 微软公司。版权所有。 。 ____ ...


Spring Boot api 在多次成功的 200 响应后给出 403

我有一个 Spring Boot 应用程序,它使用 spring security 作为依赖项。我正在将 Spring boot 版本从 2.7.16 迁移到 3.2.1。在 2.7.16 版本中一切正常。但在 3.2.1 中,其余 API 都...


如何在Spring 3.0中实现Scaffolding

“我正在使用 spring maven 项目,想要在其中实现脚手架,以便我可以根据模型动态生成 DAO、服务和 spring 表单。如何实现?”


来自有序字典的Python Json

我正在尝试创建一个嵌套的 Json 结构,如下所示: 示例 Json: { “id”:“德”, “密钥”:“1234567”, “来自”:“[email protected]”, “过期”:“2018-04-2...


如何使用xslt将xml中的文本转换为html中的超链接

如何使用 xslt 将 xml 中的文本转换为 html 中的超链接。 我的 Xml 代码是 C:\测试\CaptureF15165617TC001_05_06_1516_57_11.png 如何使用 xslt 将 xml 中的文本转换为 html 中的超链接。 我的Xml代码是 <Steps> <Filepath>C:\Test\Capture\050615165617TC001_05_06_1516_57_11.png</Filepath> </Steps> 将其转换为 html,我的 xslt 代码如下 <td width='15%'> <xsl:element name="a"> <xsl:attribute name="href"> <xsl:value-of select="./Filepath"/> </xsl:attribute> <xsl:value-of select="./Filepath"/> </xsl:element> </td> 现在这段代码在html中写入文件的整个路径,但我只想在html中写入“文件”以及指向文件位置的超链接。 我当前生成的html代码如下 C:\Test\Capture\050615165617TC001_05_06_1516_57_11.png <td width="15%"><a href="C:\Test\Capture\050615165617TC001_05_06_1516_57_11.png">C:\Test\Capture\050615165617TC001_05_06_1516_57_11.png</a></td> 我想要的是 <td width="15%"><a href="C:\Test\Capture\050615165617TC001_05_06_1516_57_11.png">File</a></td> 任何人都可以帮助我需要在 xslt 中进行哪些更改。 你告诉它具有价值: <xsl:element name="a"> <xsl:attribute name="href"> <xsl:value-of select="./Filepath"/> </xsl:attribute> <xsl:value-of select="./Filepath"/> <!--This is the link text --> </xsl:element> 所以将其更改为: <xsl:element name="a"> <xsl:attribute name="href"> <xsl:value-of select="./Filepath"/> </xsl:attribute> File </xsl:element> 或者简短地说: <a href="{Filepath}">File</a> <Steps> <Filepath>C:\Test\Capture\050615165617TC001_05_06_1516_57_11.png</Filepath> </Steps>


Spring Boot 集成测试抛出错误“java.lang.IllegalStateException:阻塞读取超时 5000 毫秒”

问题发生在我通过 Spring boot 2.0.0.M3 使用 Spring webflux 的项目上。以下是项目的依赖项, 依赖项{ 编译 'org.springframework.boot:spring-boot-starter-


mod_rewrite到子目录中相应的php文件

我想使用 mod_rewrite (在 .htaccess 中)将“干净”的 URL 映射到子目录中相应的 php 文件,例如: https://example.com/test/ --> https://example.com/p/test.php 我的...


AWS sts 在一个命令中承担角色

要在 CLI 中承担 AWS 角色,我执行以下命令: aws sts 假设角色 --role-arn arn:aws:iam::123456789123:role/myAwesomeRole --role-session-name test --region eu-central-1 这给...


ASP Fix/Int 函数未按预期运行

在调试时,我在自定义 RoundMid() 函数中发现了这个奇怪的事情: 测试 = 148.325 * 100 + 0.5 Response.Write 测试 ' 返回 14833 Response.Write Fix(test) ' 返回 14832 ??????...


React 应用程序如何连接到 OAuth 2 Spring 授权服务器/资源服务器/oauth 客户端后端

我已经实现了一个生成令牌的 OAuth 2 spring 授权服务器。端口4002 用于 api 调用的 spring 资源服务器。端口4003 一个 spring oauth 客户端,用于处理与


Spring Boot JSP 404.Whitelabel 错误页面

无法使用 spring-boot 加载非常简单的 JSP 页面,出现 404 Not Found HmisApplication.class @SpringBootApplication 公共类 HmisApplication 扩展 SpringBootServletInitializer { @覆盖


如何从.Net Core中的Content.ReadAsStringAsync方法获取字符串?

我正在尝试读取 WEB API 的响应,该响应返回字符串。 我使用下面的语句: response.Conent.ReadAsStringAsync().Result.ToString(); 我期待结果是“TEST”...


通过 Maven Spring Boot 插件运行应用程序时如何设置 Java Xmx 标志?

我正在使用 mvn spring-boot:run 运行应用程序。我正在尝试按照此处所述设置 Xmx 标志: mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Xmx512m" 但它不...


为什么将迭代器 '(vector<int> a).begin()' 传递给参数 'vector<T>::iterator b' 时无法推断 'T' 的类型?

有以下代码: 模板 void test(const typename std::vector::iterator &i){ } int main(int argc, char **argv) { std::向量 a; 测试(a.


如何使用 Java 17、Spring 6、Jakarta Server Faces 4.x 和 PrimeFaces 12 检索 FacesContext?

我正在尝试将我的 JSF + PrimeFaces (UI) + Spring 应用程序从 Java 8 迁移到 Java 17,同时还将 Spring 版本迁移到 6。 为此,需要从 javax 库移出...


Java Spring Boot:异常处理

Java Spring Boot 风格的 Web 服务有点新鲜——所以请保持温柔。为什么大多数 Spring Boot 控制器示例没有显示捕获任何异常?我看到我的一些同伴正在开发...


MySQL 事件——执行需要 EVENT 权限吗?

MySQL 5.7 (Win) 和 MariaDB 10.1 (Linux),事件计划程序设置为 ON,我以 root 身份连接。 创建数据库“事件测试”; 创建用户“event-test”@“localhost”,由“password-is-here”标识; 格...


Springboot 3.2.1(使用 Jetty)和 graphql-spqr-spring-boot-starter 1.0.0 出现错误

刚刚将 Spring Boot 升级到版本 3.2.1(使用 Jetty)并开始出现以下错误。知道如何解决这个问题吗?或者 graphql-spqr-spring-boot-starter:1.0.0 仅与旧版本兼容...


xcodebuild 在使用 test-without-building 时忽略 testPlan

考虑这个示例项目:https://github.com/stremsdoerfer/TestPlan。这只是一个 Hello World,它有两个测试计划:仅运行单元测试的 TestPlanUnit 和仅运行 UI 测试的 TestPlanUI...


Spring找不到指定的Bean

我有一个 Spring 应用程序,它使用 JpaRepository 连接到 h2,但出现以下错误: com.julio.demo.DemoApplication 中的字段 usuarioRepository 需要类型为 'com....


如何在 RTL 测试中使用 React Redux useDispatch 钩子?

我想在使用 redux 调度后测试 React 组件。我正在使用“test-utils.ts”文件中的自定义渲染函数: 从 'react' 导入 { ReactElement } 导入{渲染,渲染O...


本地运行测试时如何禁用 Spring Cloud Google Secret Manager 4.x+?

我们使用的是 spring boot 3.2,我们正在尝试将 spring-cloud-gcp-starter-secretmanager 从版本 3.2.1 升级到 4.9.0。当我们这样做时,我们的集成测试会失败,并显示: java.lang.


Spring Security 6 POST 请求未经permitAll()授权

我正在使用 Spring Boot 3、Spring Security 6。我的安全配置无法正常工作。我有 2 条路径,任何请求都应该被允许,而对于其他所有请求,都需要进行身份验证...


Hyperledger Fabric 测试网络:$ sudo ./network.sh up(不起作用)

我是超级账本结构的新手,在设置测试网络时遇到错误。 我从 docker-compose github 存储库下载了 Fabric-samples。 然后将目录更改为 test-network。 不...


Apache Tiles 3.x 不再在 Spring 6.x 中编译,因为 javax.* 重命名为 jakarta。*

我的应用程序使用Spring 5.x,Apache Tiles 3.0.x。现在我想迁移到 Spring 6.x,但问题出在 Apache Tiles 3.0.x 上,因为它有 javax.servlet.* 而不是 jakarta.* 。所有春天...


Spring security 6.2 JSESSIONID 未返回

我正在使用 Kotlin 创建一个 Spring Boot 应用程序。我已经将 WebSecurity 配置为: @配置 类安全配置{ @Autowired Lateinit var dataSource: 数据源 @值(...


在 Spring Boot 3.2.0 中使用 JdbcTemplate 将 Java LocalDate 持久化到 Oracle DATE 列时出现意外的时间组件插入

在 Spring Boot 3.2.0 中使用 JdbcTemplate 将 Java LocalDate 值保留在 Oracle DATE 列中时,我们遇到了意外行为。 在升级到 Spring Boot 3.2.0 之前,时间


使用 Hibernate - Oracle DB 在 Spring Boot 2.3.5 版本中设置 JPA 方法的超时

我正在使用 Spring Boot 2.3.5 版本和 Oracle 12c DB,并使用 Spring Boot 数据 jpa/hibernate 执行数据库操作。 有时数据库操作需要更多时间,我需要设置时间...


无法从S3存储桶下载文件。 (Langchain + s3)

我正在编写一个项目,使用s3来存储文件pdf,并使用langchain来连接和加载文件。 这是我的代码: const loader = new S3Loader({ bucket: process.env.BUCKET, key: filekey, // 示例: test/


尝试部署我的 Aave 闪贷测试但出现错误。 https://github.com/aave/flashloan-box

每当我运行“truffle test”时,我都会收到以下错误: 错误:助记符无效或未定义 在 checkBIP39Mnemonic (C:\Users\Jackc ode_modules\@truffle\hdwallet-provider\src\index.ts:...


如何在 Foundry 中的 Sepolia 测试网上运行测试?

我知道可以在 Foundry 中的分叉测试网上运行测试 伪造测试 --fork-url SEPOLIA_RPC_URL 或者 forge test --rpc-url SEPOLIA_RPC_URL #与 --fork-url 结果相同 但如果我想要...


如何以编程方式调用junit5 @ParameterizedTest?

我有一堆junit 5测试,其中一些是参数化的,我想从java类中调用它们。 当保存在 src/test 中时,测试通过 IDE 或使用 gradle clean build 成功运行


Maven:在编译中排除 java 文件

我有一个java源文件夹,我希望将其从编译中排除。 我的文件夹位于 qa/apitests/src/main/java/api/test/omi 下。 我在 qa/bamtests 下的 pom.xml 中添加了以下条目...


使用 Visual Studio 2020 在 C++ 中使用 google test 设置/配置单元测试

如果您无法编译解决方案,例如收到未解决的外部错误,请查看答案部分并重新创建其中列出的步骤。


如何限制Spring Batch作业的多个实例运行?

我的 Spring 批处理由 Rest 端点触发。我正在寻找一次仅运行一个作业实例的解决方案。


Kotlin maven 插件忽略 jvmTarget

Spring Boot:3.2.0,Kotlin:1.9.21,构建映像:maven:3.9.5-amazoncorretto-21,运行映像:amazoncorretto:17 我有一个非常简单的 Spring Boot 项目 @SpringBootApplication 类演示应用程序 有趣


© www.soinside.com 2019 - 2024. All rights reserved.