我正在开发一个Spring Boot应用程序,当我尝试使用嵌入式数据库(HSQLDB或H2,内存或文件)运行应用程序时,我收到以下错误,即使端口未被使用:org.apache.catalina.LifecycleException: Failed to start component [Conn...
我正在开发一个Spring Boot应用程序,当我尝试使用嵌入式数据库(HSQLDB或H2,内存或文件)运行应用程序时,我收到以下错误,即使端口未被使用:
org.apache.catalina.LifecycleException: Failed to start component [Connector[HTTP/1.1-9080]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:158) ~[tomcat-embed-core-8.5.4.jar:8.5.4]
at org.apache.catalina.core.StandardService.addConnector(StandardService.java:225) ~[tomcat-embed-core-8.5.4.jar:8.5.4]
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.addPreviouslyRemovedConnectors(TomcatEmbeddedServletContainer.java:234) [spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletContainer.java:179) [spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.startEmbeddedServletContainer(EmbeddedWebApplicationContext.java:297) [spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:145) [spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544) [spring-context-4.3.2.RELEASE.jar:4.3.2.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) [spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:369) [spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:313) [spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185) [spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174) [spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
at br.com.mixavionics.GsmApplication.main(GsmApplication.java:10) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_91]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_91]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_91]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_91]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-1.4.0.RELEASE.jar:1.4.0.RELEASE]
Caused by: org.apache.catalina.LifecycleException: service.getName(): "Tomcat"; Protocol handler start failed
at org.apache.catalina.connector.Connector.startInternal(Connector.java:1042) ~[tomcat-embed-core-8.5.4.jar:8.5.4]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152) ~[tomcat-embed-core-8.5.4.jar:8.5.4]
... 18 common frames omitted
Caused by: java.io.IOException: Unable to establish loopback connection
at sun.nio.ch.PipeImpl$Initializer.run(Unknown Source) ~[na:1.8.0_91]
at sun.nio.ch.PipeImpl$Initializer.run(Unknown Source) ~[na:1.8.0_91]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_91]
at sun.nio.ch.PipeImpl.<init>(Unknown Source) ~[na:1.8.0_91]
at sun.nio.ch.SelectorProviderImpl.openPipe(Unknown Source) ~[na:1.8.0_91]
at java.nio.channels.Pipe.open(Unknown Source) ~[na:1.8.0_91]
at sun.nio.ch.WindowsSelectorImpl.<init>(Unknown Source) ~[na:1.8.0_91]
at sun.nio.ch.WindowsSelectorProvider.openSelector(Unknown Source) ~[na:1.8.0_91]
at java.nio.channels.Selector.open(Unknown Source) ~[na:1.8.0_91]
at org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector(NioSelectorPool.java:66) ~[tomcat-embed-core-8.5.4.jar:8.5.4]
at org.apache.tomcat.util.net.NioSelectorPool.open(NioSelectorPool.java:130) ~[tomcat-embed-core-8.5.4.jar:8.5.4]
at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:247) ~[tomcat-embed-core-8.5.4.jar:8.5.4]
at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:874) ~[tomcat-embed-core-8.5.4.jar:8.5.4]
at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:573) ~[tomcat-embed-core-8.5.4.jar:8.5.4]
at org.apache.catalina.connector.Connector.startInternal(Connector.java:1035) ~[tomcat-embed-core-8.5.4.jar:8.5.4]
... 19 common frames omitted
Caused by: java.net.SocketException: Permission denied: connect
at sun.nio.ch.Net.connect0(Native Method) ~[na:1.8.0_91]
at sun.nio.ch.Net.connect(Unknown Source) ~[na:1.8.0_91]
at sun.nio.ch.Net.connect(Unknown Source) ~[na:1.8.0_91]
at sun.nio.ch.SocketChannelImpl.connect(Unknown Source) ~[na:1.8.0_91]
at java.nio.channels.SocketChannel.open(Unknown Source) ~[na:1.8.0_91]
at sun.nio.ch.PipeImpl$Initializer$LoopbackConnector.run(Unknown Source) ~[na:1.8.0_91]
... 34 common frames omitted
我已经尝试了-Djava.net.preferIPv4Stack = true选项,更改了端口,也禁用了防火墙,但未成功(我是该机器的管理员).在我的Linux机器(Linux Mint)上,应用程序(使用HSQLDB / H2)运行良好且没有错误,并且在带有MySql服务器的Windows 10机器上运行应用程序,应用程序也运行正常…
我错过了什么?
我的application.properties文件:
spring.datasource.url = jdbc:hsqldb:mem:test
#spring.datasource.url = jdbc:hsqldb:file:./database/database
spring.datasource.driver-class-name=org.hsqldb.jdbc.JDBCDriver
spring.jpa.database-platform=org.hibernate.dialect.HSQLDialect
spring.datasource.username = sa
spring.datasource.password = sa
我的pom.xml依赖项:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
解决方法:
似乎HSQLDB / H2仍在运行.你可以杀死所有java应用程序的过程并尝试再次运行吗?!
本文标题为:java – Spring Boot HSQLDB / H2在Windows 10上始终显示“端口已在使用中”
基础教程推荐
- 关于JSCH使用自定义连接池的说明 2023-06-02
- Java设计模式之解释器模式 2023-06-06
- 使用maven shade插件解决项目版本冲突详解 2023-05-08
- 使用JSON.toJSONString格式化成json字符串时保留null属性 2023-01-13
- Spring 代码技巧梳理总结让你爱不释手 2023-01-18
- Spring注解Autowired的底层实现原理详解 2023-06-24
- MyBatis-Plus多表联查(动态查询)的项目实践 2023-04-07
- java如何删除以逗号隔开的字符串中某一个值 2023-02-10
- java – Hibernate并发插入(MySQL INSERT IGNORE) 2023-11-03
- Spring Cloud Ribbon的使用原理解析 2023-03-11