我在 Scala 中有一个简单的休息服务器。通过 intellij 运行这个项目localhost:8080
。我试图通过邮递员和 curl 向该服务器发送POST
或GET
请求,但它无法连接它,不知道为什么。我 ping 了 localhost 并且它回答了,但是应用程序运行的 localhost:8080 仅加载,仅此而已。我运行 intellij 并启动我的服务器(scala、cats、Blaze)。昨天一切正常,但今天却不行。我查看了 intellij 日志,它们看起来不错:
2019-04-21 19:29:08,912 [14101080] INFO - ij.compiler.impl.CompileDriver - COMPILATION STARTED (BUILD PROCESS)
2019-04-21 19:29:08,919 [14101087] INFO - j.compiler.server.BuildManager - Using preloaded build process to compile /home/project
2019-04-21 19:29:11,565 [14103733] INFO - lij.compiler.impl.CompilerUtil - COMPILATION FINISHED (BUILD PROCESS); Errors: 0; warnings: 0 took 2662 ms: 0 min 2sec
2019-04-21 19:29:11,565 [14103733] INFO - s.CompilerReferenceServiceBase - backward reference index reader doesn't exist
2019-04-21 19:29:12,358 [14104526] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stdout]: Build process started. Classpath: /home/intellij/idea-IU-183.5912.21/lib/jps-launcher.jar:/usr/lib/jvm/java-1.11.0-openjdk-amd64/lib/tools.jar:/home/intellij/idea-IU-183.5912.21/lib/optimizedFileManager.jar
2019-04-21 19:29:12,419 [14104587] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
2019-04-21 19:29:12,419 [14104587] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: SLF4J: Defaulting to no-operation (NOP) logger implementation
2019-04-21 19:29:12,419 [14104587] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
2019-04-21 19:29:14,496 [14106664] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: WARNING: An illegal reflective access operation has occurred
2019-04-21 19:29:14,496 [14106664] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: WARNING: Illegal reflective access by com.google.protobuf.UnsafeUtil (file:/home/intellij/idea-IU-183.5912.21/lib/protobuf-java-3.4.0.jar) to field java.nio.Buffer.address
2019-04-21 19:29:14,496 [14106664] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: WARNING: Please consider reporting this to the maintainers of com.google.protobuf.UnsafeUtil
2019-04-21 19:29:14,496 [14106664] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
2019-04-21 19:29:14,496 [14106664] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: WARNING: All illegal access operations will be denied in a future release
一切都很好。我不知道问题可能出在哪里。我也尝试在邮递员中打开代理,但没有帮助。清除了intellij中的缓存,没有任何帮助。我正在使用最新的 Ubuntu。有没有人有同样的问题并且知道如何解决它?也许这是一个愚蠢的问题,但我真的不知道会发生什么。
编辑8080
我用这个命令
检查了是否有其他东西使用端口: netstat -tulpn | grep 8080
,但我只得到一个结果:
tcp6 0 0 127.0.0.1:8080 :::*LISTEN 18125/java
. 看起来只有我正在运行的应用程序正在使用此端口。
那是对的。只有您的服务器应该使用该端口。没有其他东西试图连接到它。
试试:
telnet 127.0.0.1 8080
。如果你回来(你应该,给定的输出
netstat
)然后端口是打开的。你的代码在做什么超出了本论坛的范围;试试scala论坛吧?