我有一个带有mysql数据库连接和junit测试类的spring引导应用程序。在本地机器上运行得很好。但是,当我将代码推到Gitlab以构建CI/CD管道时,由于mysql连接问题,构建阶段失败了。
application.yml
spring:
datasource:
driverClassName: com.mysql.cj.jdbc.Driver
#url of the mysql database
url: jdbc:mysql://localhost:3306/usermanagementdb?createDatabaseIfNotExist=true
由于mysql在Debian 10上使用了mariadb,所以我在我的Java项目中出现了数据库连接问题。我使用HikariCP进行连接,我更新了代码,以便它与mariadb一起工作:
HikariConfig hikariConfig = new HikariConfig();
hikariConfig.setMaximumPoolSize(10);
hikariConfig.setDriverClassName("org.mariadb.jdbc.Driver"); // added after internet research about hik
我的单元测试不时会失败,而且更多的时候是因为测试部分越来越大,所以我得到了以下错误:
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Data source rejected establishment of connection, message from server: "Too many connections"
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
我试图在linux机器上运行jmeter。它抛出此警告,j量表无法正常工作。
[warning] /usr/bin/jmeter: No JAVA_CMD set for run_java, falling back to JAVA_CMD = java
java.lang.Throwable: Could not access /usr/share/jmeter/lib/junit
at org.apache.jmeter.NewDriver.<clinit>(NewDriver.java:97)
我已经安装了JUNIT和JDBC.MYSQL连接器。
另外,当我设置测试用户时,它
我正在构建一个使用MySQL数据库的Spring Boot应用程序。我可以使用DBUnit运行集成测试来测试数据库,但是如果我在Docker容器中运行相同的数据库,DBUnit会失败,并显示一个错误:
org.dbunit.dataset.NoSuchTableException: Did not find table 'spring_session_attributes' in schema 'null'
at org.dbunit.database.DatabaseTableMetaData.<init>(DatabaseTableMe
当使用Testcontainers构建一个JUnit测试时,我的测试挂起,直到在消息"Waiting for database connection to the available at“和容器日志之后超时,不会产生任何错误。我甚至可以使用我最喜欢的JDBC-query-tool连接到正在运行的docker容器。 目前我使用的是MySQL容器。
我使用Spring boot和JUnit5。我的应用程序可以使用几个数据库:MySQL、Clickhouse等。
为了进行集成测试,我创建了JUnit5扩展:
public class ClickHouseTestContainersExtension implements BeforeAllCallback, BeforeTestExecutionCallback {
public static final String IMAGE_NAME = "registry.mycomp.com/db/clickhouse-server:20.5.3.27";
@
我运行了我的java应用程序,下面的日志出现了一个问题:
org.hibernate.exception.GenericJDBCException: could not insert: [com.abc.a.entity.Employee]
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.ja
我正在尝试使用maven和java来设计一个应用程序。它的一部分连接到一个MySQL数据库。为了做到这一点,我使用了Class.forName("com.mysql.jdbc.Driver");。我还添加了运行mysql-connector-java' dependency to my pom.xml. However when I runmvn测试I receive the following error when the line连接=mysql-connector-java' dependency to my pom.xml. However when I
我试图用静态方法为类编写单元测试。
当我使用@RunWith(MockitoJUnitRunner.class)时,我的测试成功地运行,但是当我将它更改为@RunWith(SpringRunner.class)时,我得到了以下错误:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not receiv