最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】maven运行spring boot报错:ERROR HikariPool.java HikariPool-1 Exception during pool initialization Communications link failure

maven crifan 1396浏览 0评论
折腾:
【未解决】用vuejs搭建智能电力管理系统的前端页面
期间,先去运行服务端:
cd /Users/crifan/dev/dev_root/projects/xxx/src/server/xxx/xxx
java -jar target/xxx-0.0.1-SNAPSHOT.jar
结果接口不可用:
http://localhost:8080/iec104/add/

{
    "data": "68 59 F0 D2 00 00 15 A6 14 00 05 00 01 07 00 02 00 00 00 00 00 CF 5D 96 5D B2 5D 45 00 01 00 FE FF 7C 00 84 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 86 13 00 00 02 00 00 00 00 00 FE FF 00 00 00 00 98 00 00 00 00 00 02 00 00 00 00 00 "
}

{
    "timestamp": "2020-02-24T13:10:18.308+0000",
    "status": 404,
    "error": "Not Found",
    "message": "No message available",
    "path": "/iec104/add/"
}
然后尝试去试试:
mvn spring-boot:run

mvn clean package
结果都是报错:
log太多:
最后好不容易,才从终端里面找到第一个error:
2020-02-24 21:15:40,560 INFO  HikariDataSource.java:110 - HikariPool-1 - Starting...
2020-02-24 21:15:40,708 ERROR HikariPool.java:595 - HikariPool-1 - Exception during pool initialization.
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
        at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174) ~[mysql-connector-java-8.0.18.jar:8.0.18]
难道是此处mysql没启动?
com.mysql.cj.jdbc.exceptions.CommunicationsException Communications link failure
解决:com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure(真实有效)_数据库_向小凯同学学习-CSDN博客
https://blog.csdn.net/wd2014610/article/details/81065520
问题依旧:
Sequel pro中去连接试试,结果也是连不上:
Connection failed!

Unable to connect to host 127.0.0.1, or the request timed out.

Be sure that the address is correct and that you have the necessary privileges, or try increasing the connection timeout (currently 10 seconds).

MySQL said: Can't connect to MySQL server on '127.0.0.1' (61)
去搞清楚,为何mysql此处没正常启动。
参考:
【未解决】Mac中Sequel连接MySQL失败:Authentication plugin ‘caching_sha2_password’ cannot be loaded: dlopen(/usr/local/lib/plugin/caching_sha2_password.so, 2): image not found
试试:
brew services restart mysql
结果报错:
➜  ~ brew services restart mysql
==> Tapping homebrew/services
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-services'...
remote: Enumerating objects: 77, done.
remote: Counting objects: 100% (77/77), done.
remote: Compressing objects: 100% (44/44), done.
remote: Total 680 (delta 28), reused 58 (delta 20), pack-reused 603
Receiving objects: 100% (680/680), 189.17 KiB | 19.00 KiB/s, done.
Resolving deltas: 100% (267/267), done.
Tapped (39 files, 262.4KB).
Error: Formula `mysql` is not installed.
然后再去看看之前的:
【记录】mac搭建开发环境:安装MySQL
【已解决】mac中/usr/local/mysql/support-files/mysql.server中的mysql的配置文件在哪里
再去试试
➜  ~ /usr/local/mysql/support-files/mysql.server status
 ERROR! MySQL is not running, but PID file exists
➜  ~ /usr/local/mysql/support-files/mysql.server start
Starting MySQL
 SUCCESS!
➜  ~ /usr/local/mysql/support-files/mysql.server status
 SUCCESS! MySQL running (24638)
然后看到设置中的MySQL状态也是running了:
此处127.0.0.1中的mysql可以用Sequel连接了:
重新去试试maven的spring boot
mvn spring-boot:run
就可以正常运行了:
2020-02-24 21:32:34,550 INFO  Version.java:46 - HHH000412: Hibernate Core {5.4.9.Final}
2020-02-24 21:32:34,946 INFO  JavaReflectionManager.java:49 - HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-02-24 21:32:35,230 INFO  HikariDataSource.java:110 - HikariPool-1 - Starting...
2020-02-24 21:32:35,865 INFO  HikariDataSource.java:123 - HikariPool-1 - Start completed.
2020-02-24 21:32:35,914 INFO  Dialect.java:172 - HHH000400: Using dialect: com.crifan.xxx.MySQL55DialectUtf8mb4
2020-02-24 21:32:37,354 INFO  JtaPlatformInitiator.java:52 - HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-02-24 21:32:37,403 INFO  AbstractEntityManagerFactoryBean.java:416 - Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-02-24 21:32:37,481 INFO  OptionalLiveReloadServer.java:58 - LiveReload server is running on port 35729
2020-02-24 21:32:37,996 WARN  JpaBaseConfiguration.java:220 - spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2020-02-24 21:32:38,331 INFO  ExecutorConfigurationSupport.java:171 - Initializing ExecutorService 'applicationTaskExecutor'
2020-02-24 21:32:38,535 INFO  WelcomePageHandlerMapping.java:54 - Adding welcome page: class path resource [static/index.html]
2020-02-24 21:32:38,843 INFO  DirectJDKLog.java:173 - Starting ProtocolHandler ["http-nio-8080"]
2020-02-24 21:32:38,889 INFO  TomcatWebServer.java:204 - Tomcat started on port(s): 8080 (http) with context path ''
2020-02-24 21:32:38,899 INFO  StartupInfoLogger.java:61 - Started AccessingDataMysqlApplication in 10.131 seconds (JVM running for 13.403)
再去
mvn clean package
是可以的:
...


  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.2.2.RELEASE)


2020-02-24 21:33:42,798 INFO  StartupInfoLogger.java:55 - Starting GreetingTests on licrifandeMacBook-Pro.local with PID 25028 (started by crifan in /Users/crifan/dev/dev_root/projects/xxx/src/server/xxx/xxx)
2020-02-24 21:33:42,803 INFO  SpringApplication.java:651 - No active profile set, falling back to default profiles: default
2020-02-24 21:33:44,638 INFO  RepositoryConfigurationDelegate.java:127 - Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2020-02-24 21:33:45,085 INFO  RepositoryConfigurationDelegate.java:187 - Finished Spring Data repository scanning in 346ms. Found 1 JPA repository interfaces.
2020-02-24 21:33:46,338 INFO  PostProcessorRegistrationDelegate.java:330 - Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-02-24 21:33:47,288 INFO  Version.java:46 - HHH000412: Hibernate Core {5.4.9.Final}
2020-02-24 21:33:47,586 INFO  JavaReflectionManager.java:49 - HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-02-24 21:33:48,038 INFO  HikariDataSource.java:110 - HikariPool-1 - Starting...
2020-02-24 21:33:49,085 INFO  HikariDataSource.java:123 - HikariPool-1 - Start completed.
2020-02-24 21:33:49,203 INFO  Dialect.java:172 - HHH000400: Using dialect: com.crifan.xxx.MySQL55DialectUtf8mb4
2020-02-24 21:33:51,401 INFO  JtaPlatformInitiator.java:52 - HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-02-24 21:33:51,425 INFO  AbstractEntityManagerFactoryBean.java:416 - Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-02-24 21:33:52,816 WARN  JpaBaseConfiguration.java:220 - spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2020-02-24 21:33:53,592 INFO  ExecutorConfigurationSupport.java:171 - Initializing ExecutorService 'applicationTaskExecutor'
2020-02-24 21:33:53,926 INFO  WelcomePageHandlerMapping.java:54 - Adding welcome page: class path resource [static/index.html]
2020-02-24 21:33:54,590 INFO  StartupInfoLogger.java:61 - Started GreetingTests in 12.568 seconds (JVM running for 18.126)
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 16.28 s - in com.crifan.xxx.GreetingTests
2020-02-24 21:33:55,103 INFO  ExecutorConfigurationSupport.java:208 - Shutting down ExecutorService 'applicationTaskExecutor'
2020-02-24 21:33:55,104 INFO  AbstractEntityManagerFactoryBean.java:598 - Closing JPA EntityManagerFactory for persistence unit 'default'
2020-02-24 21:33:55,109 INFO  HikariDataSource.java:350 - HikariPool-1 - Shutdown initiated...
2020-02-24 21:33:55,128 INFO  HikariDataSource.java:352 - HikariPool-1 - Shutdown completed.
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] 
[INFO] --- maven-jar-plugin:3.1.2:jar (default-jar) @ xxx ---
[INFO] Building jar: /Users/crifan/dev/dev_root/projects/xxx/src/server/xxx/xxx/target/xxx-0.0.1-SNAPSHOT.jar
[INFO] 
[INFO] --- spring-boot-maven-plugin:2.2.2.RELEASE:repackage (repackage) @ xxx ---
[INFO] Replacing main artifact with repackaged archive
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  37.172 s
[INFO] Finished at: 2020-02-24T21:33:58+08:00
[INFO] ------------------------------------------------------------------------
再去:
java -jar target/xxx-0.0.1-SNAPSHOT.jar
看看是否可以。
➜  xxx git:(master) ✗ java -jar target/xxx-0.0.1-SNAPSHOT.jar


  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.2.2.RELEASE)


2020-02-24 21:34:49,352 INFO  StartupInfoLogger.java:55 - Starting AccessingDataMysqlApplication v0.0.1-SNAPSHOT on licrifandeMacBook-Pro.local with PID 25204 (/Users/crifan/dev/dev_root/projects/xxx/src/server/xxx/xxx/target/xxx-0.0.1-SNAPSHOT.jar started by crifan in /Users/crifan/dev/dev_root/projects/xxx/src/server/xxx/xxx)
2020-02-24 21:34:49,367 INFO  SpringApplication.java:651 - No active profile set, falling back to default profiles: default
2020-02-24 21:34:51,397 INFO  RepositoryConfigurationDelegate.java:127 - Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2020-02-24 21:34:51,579 INFO  RepositoryConfigurationDelegate.java:187 - Finished Spring Data repository scanning in 93ms. Found 1 JPA repository interfaces.
2020-02-24 21:34:52,295 INFO  PostProcessorRegistrationDelegate.java:330 - Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-02-24 21:34:53,129 INFO  TomcatWebServer.java:92 - Tomcat initialized with port(s): 8080 (http)
2020-02-24 21:34:53,165 INFO  DirectJDKLog.java:173 - Initializing ProtocolHandler ["http-nio-8080"]
2020-02-24 21:34:53,179 INFO  DirectJDKLog.java:173 - Starting service [Tomcat]
2020-02-24 21:34:53,188 INFO  DirectJDKLog.java:173 - Starting Servlet engine: [Apache Tomcat/9.0.29]
2020-02-24 21:34:53,363 INFO  DirectJDKLog.java:173 - Initializing Spring embedded WebApplicationContext
2020-02-24 21:34:53,364 INFO  ServletWebServerApplicationContext.java:284 - Root WebApplicationContext: initialization completed in 3783 ms
2020-02-24 21:34:53,989 INFO  Version.java:46 - HHH000412: Hibernate Core {5.4.9.Final}
2020-02-24 21:34:54,354 INFO  JavaReflectionManager.java:49 - HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-02-24 21:34:54,666 INFO  HikariDataSource.java:110 - HikariPool-1 - Starting...
2020-02-24 21:34:57,048 INFO  HikariDataSource.java:123 - HikariPool-1 - Start completed.
2020-02-24 21:34:57,288 INFO  Dialect.java:172 - HHH000400: Using dialect: com.crifan.xxx.MySQL55DialectUtf8mb4
2020-02-24 21:35:00,203 INFO  JtaPlatformInitiator.java:52 - HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-02-24 21:35:00,289 INFO  AbstractEntityManagerFactoryBean.java:416 - Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-02-24 21:35:01,990 WARN  JpaBaseConfiguration.java:220 - spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2020-02-24 21:35:03,295 INFO  ExecutorConfigurationSupport.java:171 - Initializing ExecutorService 'applicationTaskExecutor'
2020-02-24 21:35:03,757 INFO  WelcomePageHandlerMapping.java:54 - Adding welcome page: class path resource [static/index.html]
2020-02-24 21:35:04,178 INFO  DirectJDKLog.java:173 - Starting ProtocolHandler ["http-nio-8080"]
2020-02-24 21:35:04,244 INFO  TomcatWebServer.java:204 - Tomcat started on port(s): 8080 (http) with context path ''
2020-02-24 21:35:04,248 INFO  StartupInfoLogger.java:61 - Started AccessingDataMysqlApplication in 16.3 seconds (JVM running for 18.416)
就可以正常运行了。
然后再去postman中测试
http://localhost:8080/iec104/add/

{
    "data": "68 59 F0 D2 00 00 15 A6 14 00 05 00 01 07 00 02 00 00 00 00 00 CF 5D 96 5D B2 5D 45 00 01 00 FE FF 7C 00 84 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 86 13 00 00 02 00 00 00 00 00 FE FF 00 00 00 00 98 00 00 00 00 00 02 00 00 00 00 00 "
}

{
    "id": 6,
    "data": "68 59 F0 D2 00 00 15 A6 14 00 05 00 01 07 00 02 00 00 00 00 00 CF 5D 96 5D B2 5D 45 00 01 00 FE FF 7C 00 84 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 86 13 00 00 02 00 00 00 00 00 FE FF 00 00 00 00 98 00 00 00 00 00 02 00 00 00 00 00 ",
    "parseResult": "*APCI应用规约控制信息*\n启动字符[1 byte]: 0x68 \n应用规约数据单元(APDU)长度[2 byte]:89字节\n控制域[3 byte - 6 byte]:\n\t(I格式控制域标志)\n\t发送序列号:27000\n\t接受序列号:0\n*ASDU应用服务数据单元*\n类属性标识符[7 byte]:0x15 Measured value, normalized value without quality descriptor\n可变结构限定词[8 byte]:可变结构限定词:0xA6   SQ=1 信息元素地址顺序     信息元素个数:38\n传送原因=COT[9 byte]:[T(test) bit7:0  未实验][P/N  bit6:0  肯定确认][原因  bit5~bit0:20 interrogated by general interrogation]\n发送人地址=ORG=Originator Address [10 byte]:0\n应用服务数据单元公共地址=COA=Common Address of ASDU[11 byte - 12 byte]:0005H\n信息对象地址:    1793(000701H)\n信息元素1的信息元素值 NVA: 0x02 0x00\n信息元素2的信息元素值 NVA: 0x00 0x00\n信息元素3的信息元素值 NVA: 0x00 0x00\n信息元素4的信息元素值 NVA: 0xCF 0x5D\n信息元素5的信息元素值 NVA: 0x96 0x5D\n信息元素6的信息元素值 NVA: 0xB2 0x5D\n信息元素7的信息元素值 NVA: 0x45 0x00\n信息元素8的信息元素值 NVA: 0x01 0x00\n信息元素9的信息元素值 NVA: 0xFE 0xFF\n信息元素10的信息元素值 NVA: 0x7C 0x00\n信息元素11的信息元素值 NVA: 0x84 0x02\n信息元素12的信息元素值 NVA: 0x00 0x00\n信息元素13的信息元素值 NVA: 0x00 0x00\n信息元素14的信息元素值 NVA: 0x00 0x00\n信息元素15的信息元素值 NVA: 0x00 0x00\n信息元素16的信息元素值 NVA: 0x00 0x00\n信息元素17的信息元素值 NVA: 0x00 0x00\n信息元素18的信息元素值 NVA: 0x00 0x00\n信息元素19的信息元素值 NVA: 0x00 0x00\n信息元素20的信息元素值 NVA: 0x00 0x00\n信息元素21的信息元素值 NVA: 0x00 0x00\n信息元素22的信息元素值 NVA: 0x00 0x00\n信息元素23的信息元素值 NVA: 0x00 0x00\n信息元素24的信息元素值 NVA: 0x00 0x00\n信息元素25的信息元素值 NVA: 0x86 0x13\n信息元素26的信息元素值 NVA: 0x00 0x00\n信息元素27的信息元素值 NVA: 0x02 0x00\n信息元素28的信息元素值 NVA: 0x00 0x00\n信息元素29的信息元素值 NVA: 0x00 0x00\n信息元素30的信息元素值 NVA: 0xFE 0xFF\n信息元素31的信息元素值 NVA: 0x00 0x00\n信息元素32的信息元素值 NVA: 0x00 0x00\n信息元素33的信息元素值 NVA: 0x98 0x00\n信息元素34的信息元素值 NVA: 0x00 0x00\n信息元素35的信息元素值 NVA: 0x00 0x00\n信息元素36的信息元素值 NVA: 0x02 0x00\n信息元素37的信息元素值 NVA: 0x00 0x00\n信息元素38的信息元素值 NVA: 0x00 0x00\n"
}
就正常了。
【总结】
此处,去启动spring boot的服务端:
mvn spring-boot:run
或:
mvn clean package
java -jar target/xxx-0.0.1-SNAPSHOT.jar
但是报错:
ERROR HikariPool.java:595 – HikariPool-1 – Exception during pool initialization.
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
原因:
mysql没有启动。
导致此处mysql的jdbc的Hikari连接不上。
解决办法:
此处mac中启动mysql
/usr/local/mysql/support-files/mysql.server start
即可。

转载请注明:在路上 » 【已解决】maven运行spring boot报错:ERROR HikariPool.java HikariPool-1 Exception during pool initialization Communications link failure

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
81 queries in 0.192 seconds, using 22.17MB memory