我试图从postman向我的后端spring boot容器发送请求,我得到
“无法发送请求”消息
docker-compose.yml:
version: '3'
services:
mysqldb:
image: mysql
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=booking
- MYSQL_USER=dhia
- MYSQL_PASSWORD=root
ports:
- 3308:3306
app:
image: app:latest
ports:
- 8091:8091
environment:
SPRING_DATASOURCE_URL: jdbc:mysql://mysqldb:3306/booking
depends_on:
- mysqldb
应用程序启动良好,0个错误
这是我的Dockerfile
FROM maven:3.8.6-openjdk-18-slim as MAVEN_BUILD
WORKDIR /build
COPY pom.xml .
RUN mvn dependency:go-offline
COPY src ./src
RUN mvn package -Dmaven.test.skip=true
FROM openjdk:18-alpine
WORKDIR /app
ARG JAR_FILE=*.jar
COPY --from=MAVEN_BUILD /build/target/${JAR_FILE} ./app.jar
EXPOSE 8080
CMD ["java", "-jar", "app.jar"]
bookingsystem-app-1 |
bookingsystem-app-1 | . ____ _ __ _ _
bookingsystem-app-1 | /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
bookingsystem-app-1 | ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
bookingsystem-app-1 | \\/ ___)| |_)| | | | | || (_| | ) ) ) )
bookingsystem-app-1 | ' |____| .__|_| |_|_| |_\__, | / / / /
bookingsystem-app-1 | =========|_|==============|___/=/_/_/_/
bookingsystem-app-1 | :: Spring Boot :: (v2.7.3)
bookingsystem-app-1 |
bookingsystem-app-1 | 2022-08-21 11:10:34.994 INFO 1 --- [ main] Booking.BookingApplication : Starting BookingApplication v0.0.1-SNAPSHOT using Java 18-ea on 521f32647790 with PID 1 (/app/app.jar started by root in /app)
bookingsystem-app-1 | 2022-08-21 11:10:35.005 INFO 1 --- [ main] Booking.BookingApplication : No active profile set, falling back to 1 default profile: "default"
bookingsystem-app-1 | 2022-08-21 11:10:36.215 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
bookingsystem-app-1 | 2022-08-21 11:10:36.325 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 90 ms. Found 4 JPA repository interfaces.
bookingsystem-app-1 | 2022-08-21 11:10:37.470 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8090 (http)
bookingsystem-app-1 | 2022-08-21 11:10:37.499 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
bookingsystem-app-1 | 2022-08-21 11:10:37.499 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.65]
bookingsystem-app-1 | 2022-08-21 11:10:37.637 INFO 1 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
bookingsystem-app-1 | 2022-08-21 11:10:37.638 INFO 1 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2339 ms
bookingsystem-app-1 | 2022-08-21 11:10:37.753 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
bookingsystem-app-1 | 2022-08-21 11:10:38.142 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
bookingsystem-app-1 | 2022-08-21 11:10:38.342 INFO 1 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
bookingsystem-app-1 | 2022-08-21 11:10:38.466 INFO 1 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.6.10.Final
bookingsystem-app-1 | 2022-08-21 11:10:38.792 INFO 1 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
bookingsystem-app-1 | 2022-08-21 11:10:38.946 INFO 1 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
bookingsystem-app-1 | Hibernate:
bookingsystem-app-1 |
bookingsystem-app-1 | alter table bookings
bookingsystem-app-1 | add constraint FK4xjjw8rumqxvr8c6t7xm6q8ty
bookingsystem-app-1 | foreign key (hike_id)
bookingsystem-app-1 | references hikes (id)
bookingsystem-app-1 | Hibernate:
bookingsystem-app-1 |
bookingsystem-app-1 | alter table bookings
bookingsystem-app-1 | add constraint FKg37gxkbbjvc3dp3een92kxy05
bookingsystem-app-1 | foreign key (hiker_id)
bookingsystem-app-1 | references hikers (id)
bookingsystem-app-1 | Hibernate:
bookingsystem-app-1 |
bookingsystem-app-1 | alter table hikes
bookingsystem-app-1 | add constraint FKs8qvf1tnml0ahxs407ggng3bs
bookingsystem-app-1 | foreign key (trail_id)
bookingsystem-app-1 | references trails (id)
bookingsystem-app-1 | 2022-08-21 11:10:39.988 INFO 1 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
bookingsystem-app-1 | 2022-08-21 11:10:40.000 INFO 1 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
bookingsystem-app-1 | 2022-08-21 11:10:40.542 WARN 1 --- [ main] JpaBaseConfiguration$JpaWebConfiguration : 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
bookingsystem-app-1 | 2022-08-21 11:10:41.008 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8090 (http) with context path ''
bookingsystem-app-1 | 2022-08-21 11:10:41.019 INFO 1 --- [ main] Booking.BookingApplication : Started BookingApplication in 6.813 seconds (JVM running for 7.789)
这是我的应用程序属性文件:
spring.datasource.url = jdbc:mysql://localhost:3308/booking
spring.datasource.username=root
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
spring.datasource.password=root
createDatabaseIfNotExist=true
### JPA / HIBERNATE ###
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=none
spring.jpa.generate-ddl = true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.properties.show-sql = true
spring.jpa.properties.hibernate.format_sql = true
server.port=8090
我无法访问我的控制器或发送任何请求的问题我尝试了所有的端口和所有的名称(localhost,预订,应用程序),总是CONNREFUSED
http://mysqldb:8080/hikes
超文本传输协议://mysql db: 8090/hikes
http://mysqldb:8091/hikes
http://localhost:8080/hikes
http://localhost:8090/hikes
http://localhost:8091/hikes
顺便说一句,当我在没有容器的情况下运行它时,一切都很好。
尝试使用相同的端口号dockerfile更改这些端口号-
我对docker容器(它是一个与Redis数据库通信的Node.js API)发出HTTP请求时遇到问题,该容器在VM(docker Toolbox)中运行。 我已经建立了我的Dockerfile,并docker-compose.yml了所需的端口。构建它们并成功运行(“启动”)它们。 雷迪斯。js 服务器js(express.js) 我成功地构建了容器,然后使用HTTP请求服务测试GET。因为我
我有一个. NET Core Docker容器,它无法向外部世界发送请求。我不能curl或ping任何东西,包括像8.8.8.8这样的dns记录。然而,MongoDB容器能够ping和curl到外部世界。 我尝试了几种图像: microsoft/dot net: 2.0-运行时 微软/asp网络核心 容器的传入连接工作正常。 Docker在ubuntu机器上运行。我正在使用Docker Swell
我有这个代码: 当为 true(执行 POST 或 PUT 请求)时,此代码会引发 IOException,并且不会完成请求。我尝试对 重新排序、编写调用和流创建块,但没有排列工作。 在所有情况下,BufferedReader都工作得很好,不会抛出任何异常。< code>getQuery正确返回URL编码的字符串。 以下是来自IOExc的堆栈跟踪: 最终发生的是请求通过,但没有一个POST或PUT
我试图使用eclipse或intellij向api发送get请求,作为使用java/jUnit和放心框架工作的测试的一部分。 每个请求都失败,并显示以下消息 2018年3月13日下午1:29:56组织。阿帕奇。http。impl。客户DefaultHttpClient tryConnect信息:连接到{s}时捕获到I/O异常(java.net.SocketException)- 顺便说一句,我正在
javax.net.ssl.sslhandShakeException:收到致命警报:在com.ibm.jsse2.O.A(O.java:8)在com.ibm.jsse2.sslsocketimpl.B(SSLSocketimpl.java:40)在com.ibm.jsse2.sslsocketimpl.A(SSLSocketimpl.java:554)在com.ibm.jsse2.sslsock
问题内容: 我正在尝试在Elasticsearch上执行简单的“请求正文搜索”,如以下示例所示,但使用.NET而不是curl 下面是我的.NET代码。 但是,我收到以下错误。 有什么方法可以使用标准.NET类发送带有请求的内容主体。还是有解决方法? 问题答案: 将更改为解决方法。 MSDN声明,如果使用or 方法调用该方法,则将引发a 。