Я хочу собрать файл jar из моего приложения Spring Boot, чтобы создать образ docker.
Я выбираю «пакет», соответственно. запустите maven с "package" в качестве командной строки. Вместо этого он запускает все приложение Spring Boot. В конце это терпит неудачу, потому что это обращается к dockerize mysql db. Поскольку БД и приложение Spring Boot находятся в разных сетях, оно, конечно, дает сбой:
2020-03-11 01:37:11.655 ERROR 6128 --- [ main] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Exception during pool initialization.
java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 5 times. Giving up.
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_171]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_171]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_171]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_171]
...
Caused by: java.net.UnknownHostException: shortenedurlmysqldb
Мой application.properties
файл:
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://shortenedurlmysqldb/bootdb2?createDatabaseIfNotExist=true&autoReconnect=true&maxReconnects=5&allowPublicKeyRetrieval=true&useSSL=false
spring.datasource.username=newuser
spring.datasource.password=password
spring.datasource.platform=mysql
spring.datasource.initialization-mode=always
Мой Dockerfile
:
From openjdk:8
copy ./target/jugtours-0.0.1-SNAPSHOT.jar jugtours-0.0.1-SNAPSHOT.jar
CMD ["java","-jar","jugtours-0.0.1-SNAPSHOT.jar"]
My application.yml
spring:
profiles:
active: spring.profiles.active@
security:
oauth2:
client:
registration:
okta:
client-id: [...secret...]
client-secret: [...secret...]
scope: openid, email, profile
provider:
okta:
issuer-uri: [...secret...]
Я не понимаю, с чего нужно начинать Spring Spring Boot Application. Не могу ли maven создать файл jar без запуска Spring Boot App?