我正在尝试使用Tomcat在部署和mariaDB
作为数据库的帮助下部署应用程序。
相应生成的war
文件已部署,但当我尝试访问其他页面(基本网址/目标网页除外)时,会显示以下错误:
web-app_1 | 07:20:00.324 [http-apr-8080-exec-3] INFO com.company.controller.MainController - in Main controller
web-app_1 | 07:20:00.806 [http-apr-8080-exec-3] DEBUG org.hibernate.stat.internal.StatisticsInitiator - Statistics initialized [enabled=false]
web-app_1 | 07:20:00.952 [http-apr-8080-exec-3] DEBUG org.hibernate.engine.jdbc.spi.SqlExceptionHelper - Unable to acquire JDBC Connection [n/a]
web-app_1 | java.sql.SQLNonTransientConnectionException: Could not connect to address=(host=localhost)(port=833)(type=master) : Connection refused (Connection refused)
web-app_1 | at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.get(ExceptionMapper.java:156)
web-app_1 | at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.getException(ExceptionMapper.java:118)
web-app_1 | at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.throwException(ExceptionMapper.java:92)
web-app_1 | at org.mariadb.jdbc.Driver.connect(Driver.java:108)
web-app_1 | at java.sql.DriverManager.getConnection(DriverManager.java:664)
web-app_1 | at java.sql.DriverManager.getConnection(DriverManager.java:208)
web-app_1 | at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:153)
web-app_1 | at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriver(DriverManagerDataSource.java:144)
web-app_1 | at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnectionFromDriver(AbstractDriverBasedDataSource.java:196)
和hibernate.properties
文件包含:
jdbc.driverClassName = org.mariadb.jdbc.Driver
jdbc.url = jdbc:mysql://localhost:3306/ams_dbnew
jdbc.username = username
jdbc.password = password
hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect
hibernate.hbm2ddl.auto = none
hibernate.format_sql = true
hibernate.show_sql = true
虽然指向jdbc:mysql://localhost:3306/
但在tomcat中将其显示错误记录为java.sql.SQLNonTransientConnectionException: Could not connect to address=(host=localhost)(port=833)(type=master) : Connection refused (Connection refused)
并且数据库在相同的3306
端口
sudo netstat -tulpen | grep mysql
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 121 410570 51950/mysqld
谁能告诉我哪里和哪一部分做错了?
和docker-compose
文件是:
version: '3'
services:
web-app:
build:
context: .
dockerfile: Dockerfile
ports:
- 8080:8080
network_mode: "host"
答案 0 :(得分:0)
我怀疑端口833,尝试搜索号码" 833"在您的tomcat主目录中
cd /TOMCAT_HOME_DIRECTORY/
grep -rli 833 .
可能是覆盖端口号的文件之一。