-
Notifications
You must be signed in to change notification settings - Fork 9
Execution
The setup configuration file can be found on .run\LearningSpringBootApplication.run.xml
:
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="LearningSpringBootApplication" type="Application" factoryName="Application">
<option name="ALTERNATIVE_JRE_PATH" value="BUNDLED" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
<option name="MAIN_CLASS_NAME" value="com.josephrodriguez.learning.springboot.LearningSpringBootApplication" />
<module name="Learning.SpringBoot" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
You can download Maven and install it according the installation guide steps here. This is the information of Maven version used:
$ mvn --version
Apache Maven 3.8.3 (ff8e977a158738155dc465c6a97ffaf31982d739)
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
To run the application execute the command at root of the repository folder:
$ mvn spring-boot:run
In the same way you can use the Maven Wrapper plugin on the repository source code:
$ ./mvnw spring-boot:run
As we analyze in this articule Docker multi-stage build for Spring Boot application this is the best solution that I found for this image building. Please let me know of any improvements!!!!!
Dockerfile:
FROM openjdk:8-jdk-alpine as build
COPY . /usr/app
WORKDIR /usr/app
RUN chmod +x mvnw && ./mvnw clean package
FROM openjdk:8-jre-alpine
COPY --from=build /usr/app/target/*.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java","-jar","app.jar"]
We can build the application image with the command:
$ docker build -t josephrodriguez/learning-spring-boot -f ./Dockerfile .
Also you can download and run the Docker image from Docker Hub:
$ docker run -p 8080:8080 josephrodriguez/learning-spring-boot
docker-compose.yml:
version: "3.8"
services:
app:
build:
context: .
dockerfile: Dockerfile
ports:
- "8080:8080"
Execute the command to run the application:
docker-compose up --build
In any case you should see an output very similar to this:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.5.5)
2021-10-22 05:18:50.027 INFO 1 --- [ main] c.j.l.s.LearningSpringBootApplication : Starting LearningSpringBootApplication v0.0.1 using Java 1.8.0_212 on 918a8f312eb5 with PID 1 (/app/target/learning-spring-boot-0.0.1.jar started by root in /app)
2021-10-22 05:18:50.037 INFO 1 --- [ main] c.j.l.s.LearningSpringBootApplication : No active profile set, falling back to default profiles: default
2021-10-22 05:18:51.804 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2021-10-22 05:18:51.807 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JDBC repositories in DEFAULT mode.
2021-10-22 05:18:51.850 INFO 1 --- [ main] .RepositoryConfigurationExtensionSupport : Spring Data JDBC - Could not safely identify store assignment for repository candidate interface com.josephrodriguez.learning.springboot.data.repository.DocumentRepository. If you want this repository to be a JDBC repository, consider annotating your entities with one of these annotations: org.springframework.data.relational.core.mapping.Table.
2021-10-22 05:18:51.851 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 36 ms. Found 0 JDBC repository interfaces.
2021-10-22 05:18:51.865 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2021-10-22 05:18:51.867 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-10-22 05:18:51.920 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 42 ms. Found 1 JPA repository interfaces.
2021-10-22 05:18:52.496 INFO 1 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.ws.config.annotation.DelegatingWsConfiguration' of type [org.springframework.ws.config.annotation.DelegatingWsConfiguration$$EnhancerBySpringCGLIB$$b28885a6] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-10-22 05:18:52.592 INFO 1 --- [ main] .w.s.a.s.AnnotationActionEndpointMapping : Supporting [WS-Addressing August 2004, WS-Addressing 1.0]
2021-10-22 05:18:53.261 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2021-10-22 05:18:53.283 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2021-10-22 05:18:53.284 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.53]
2021-10-22 05:18:53.376 INFO 1 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2021-10-22 05:18:53.376 INFO 1 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 3171 ms
2021-10-22 05:18:53.443 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2021-10-22 05:18:53.991 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2021-10-22 05:18:54.001 INFO 1 --- [ main] o.s.b.a.h2.H2ConsoleAutoConfiguration : H2 console available at '/h2'. Database available at 'jdbc:h2:file:./data/learning.spring.boot'
2021-10-22 05:18:54.399 INFO 1 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2021-10-22 05:18:54.523 INFO 1 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.32.Final
2021-10-22 05:18:54.833 INFO 1 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2021-10-22 05:18:55.071 INFO 1 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2021-10-22 05:18:55.908 INFO 1 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-10-22 05:18:55.930 INFO 1 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2021-10-22 05:18:56.568 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
2021-10-22 05:18:58.544 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2021-10-22 05:18:58.567 INFO 1 --- [ main] c.j.l.s.LearningSpringBootApplication : Started LearningSpringBootApplication in 9.426 seconds (JVM running for 10.534)