Skip to content

Commit 5c336f2

Browse files
committed
feat(h2): database
- add configuration - add dependency
1 parent 5a7a15b commit 5c336f2

File tree

8 files changed

+40
-61
lines changed

8 files changed

+40
-61
lines changed

CHANGELOG.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,15 @@
2525
- Implementación de CRUD para la entidad `Application` ejemplo básico.
2626
- Implementación de excepciones global para capturar y manejar excepciones personalizadas.
2727
- Gestion de dependencias con **Maven** y **Gradle**
28+
---
2829

2930

30-
### Cambiado
31-
- No cambios.
31+
### Cambiado 2024-11-11
32+
- Entorno de Desarrollo y Pruebas: Velocidad, Simplicidad, Reseteo Rápido
33+
- Cambio archivos de configuración: application.yml
34+
- Cambio de dependencia base de datos H2
3235

33-
### Corregido
34-
- No correcciones
36+
### Corregido 2024-11-11
37+
- Nombre de paquete exceptions
3538

36-
---
39+
---

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,21 @@
2424
# 🧩 Descripción general
2525

2626
Este arquetipo proporciona una estructura básica para iniciar proyectos en Java utilizando el framework Spring. Está
27-
diseñado para facilitar el desarrollo rápido y eficiente de aplicaciones web.
27+
diseñado para facilitar el desarrollo rápido y eficiente de aplicaciones rest.
2828

2929
# 🔖 Características
3030

3131
## 📋 Requisitos
3232

3333
Asegúrate de tener instalado:
3434

35-
- Java OpenJDK 11
35+
- Java OpenJDK 21
3636
- Maven 3.6 o superior
3737
- Git
3838

3939
| Herramienta | Version | Recurso |
4040
|--------------|:-------:|-----------------------------------------------------------------------------------------------------------------------------------|
41-
| Java OpenJDK | 11 | [resources](https://jdk.java.net/java-se-ri/11-MR3) |
41+
| Java OpenJDK | 21 | [resources](https://jdk.java.net/java-se-ri/21) |
4242
| Maven | 3.6.2 | [resources](https://archive.apache.org/dist/maven/maven-3/3.6.2/) |
4343
| Git | latest | [win](https://git-scm.com/downloads/win), [mac](https://git-scm.com/downloads/mac), [linux](https://git-scm.com/downloads/linux) |
4444

@@ -73,7 +73,7 @@ mvn archetype:generate \
7373
-DartifactId=archetype-example \
7474
-Dversion=1.0.0 \
7575
-Dversion=1.0.0 \
76-
-DpackageName=microservice/application \
76+
-DpackageName=microservice \
7777
-Dpackage=com.example \
7878
-DinteractiveMode=false
7979
```
@@ -88,7 +88,7 @@ mvn archetype:generate ^
8888
-DgroupId=com.example ^
8989
-DartifactId=archetype-example ^
9090
-Dversion=1.0.0 ^
91-
-DpackageName=microservice/application ^
91+
-DpackageName=microservice ^
9292
-Dpackage=com.example ^
9393
-DinteractiveMode=false
9494
```
@@ -136,17 +136,17 @@ Disk:
136136

137137
## 🔧 Tecnologías Usadas
138138

139-
| java | Spring Boot | Gradle | Maven | Branch |
140-
|:------:|:-----------:|:----------:|----------------|-------------|
141-
| jdk-11 | 2.* | gradle-8.5 | 3.6 o superior | [console]() |
139+
| java | Spring Boot | Gradle | Maven | Branch |
140+
|:----------:|:-----------:|:----------:|----------------|------------------------------------------------------------------------------------------------|
141+
| openJDK-21 | 3.* | gradle-8.5 | 3.6 o superior | [console](https://github.com/dbacilio88/archetype-api-microservices/tree/spring-boot-3-jdk-21) |
142142

143143
## ⚙️ Configuración rápida
144144

145145
Incluye configuraciones predeterminadas para Spring Boot.
146146

147147
## 🧰 Integración de dependencias
148148

149-
Configuración básica de Maven para gestionar dependencias.
149+
Configuración básica de Maven o Gradle para gestionar dependencias.
150150

151151
## 📦 Ejemplo de código
152152

@@ -159,6 +159,8 @@ Incluye ejemplos de controladores, servicios y repositorios.
159159
Puedes agregar tus propios controladores, servicios y repositorios en las carpetas correspondientes. Modifica
160160
`application.properties` o `application.yml` para configurar tu aplicación según sea necesario.
161161

162+
Nota: ejecutar el componente o aplicación en perfil **`dev`**
163+
162164
# 👨🏻‍💻 Contribuciones
163165

164166
¿Cómo puedes ayudar?

src/main/resources/application.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/main/resources/archetype-resources/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ dependencies {
7171

7272
// dependencies app build
7373
implementation group: 'org.springframework.boot', name: 'spring-boot-starter', version: '3.3.0'
74-
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-webflux', version: '3.3.0'
74+
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '3.3.0'
7575
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-actuator', version: '3.3.0'
7676
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-validation', version: '3.3.0'
7777
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version: '3.3.0'
@@ -82,11 +82,11 @@ dependencies {
8282
implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.23.1'
8383

8484
// dependencies app database
85-
implementation group: 'org.postgresql', name: 'postgresql', version: '42.7.2'
85+
implementation group: 'com.h2database', name: 'h2', version: '2.2.224'
8686

8787
// dependencies app documentation swagger
88-
implementation group: 'org.springdoc', name: 'springdoc-openapi-starter-webflux-ui', version: '2.6.0'
89-
implementation group: 'org.springdoc', name: 'springdoc-openapi-starter-webflux-api', version: '2.6.0'
88+
implementation group: 'org.springdoc', name: 'springdoc-openapi-starter-webmvc-ui', version: '2.6.0'
89+
implementation group: 'org.springdoc', name: 'springdoc-openapi-starter-webmvc-api', version: '2.6.0'
9090

9191
//compiled annotation processor
9292
annotationProcessor group: 'org.springframework.boot', name: 'spring-boot-configuration-processor', version: '3.3.0'

src/main/resources/archetype-resources/pom.xml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@
7979

8080
<!--dependencies app database-->
8181
<dependency>
82-
<groupId>org.postgresql</groupId>
83-
<artifactId>postgresql</artifactId>
84-
<version>42.7.4</version>
82+
<groupId>com.h2database</groupId>
83+
<artifactId>h2</artifactId>
84+
<scope>runtime</scope>
8585
</dependency>
8686

8787
<!--dependencies app documentation swagger-->
@@ -133,11 +133,6 @@
133133
<artifactId>spring-boot-starter-test</artifactId>
134134
</dependency>
135135

136-
<dependency>
137-
<groupId>com.h2database</groupId>
138-
<artifactId>h2</artifactId>
139-
</dependency>
140-
141136
</dependencies>
142137

143138
<build>

src/main/resources/archetype-resources/src/main/java/__packageName__/components/exceptions/handler/GlobalExceptionHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package ${package}.${packageName.replace('/','.')}.components.exceptions.handler;
22

3-
import com.example.microservice.application.components.exceptions.CommonException;
3+
import ${package}.${packageName.replace('/','.')}.components.exceptions.CommonException;
44
import org.springframework.http.HttpStatus;
55
import org.springframework.http.MediaType;
66
import org.springframework.http.ResponseEntity;

src/main/resources/archetype-resources/src/main/resources/application-dev.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@ spring:
33
jpa:
44
open-in-view: false
55
show-sql: false
6-
#database: postgresql # Postgres SQLDialect does not need to be specified explicitly using 'hibernate.dialect' (remove the property setting, and it will be selected by default)
76
hibernate:
8-
ddl-auto: none
7+
ddl-auto: create # Creates the database schema from scratch every time the application starts. This means all existing tables are dropped and recreated, which is useful in development environments where data is not critical.
98
properties:
109
hibernate:
11-
#dialect: org.hibernate.dialect.PostgreSQLDialect # Postgres SQLDialect does not need to be specified explicitly using 'hibernate.dialect' (remove the property setting, and it will be selected by default)
1210
show_sql: true
1311
format_sql: true
1412

@@ -26,7 +24,13 @@ spring:
2624
maximum-pool-size: 20 # This property controls the maximum size that the pool is allowed to reach, including both idle and in-use connections. Basically this value will determine the maximum number of actual connections to the database backend, default: 10
2725
validation-timeout: 5000 # This property controls the maximum amount of time that a connection will be tested for aliveness. This value must be less than the :connection-timeout. The lowest accepted validation timeout is 1000ms (1 second)
2826

29-
url: jdbc:postgresql://localhost:5432/postgres?currentSchema=public
30-
username: postgres
31-
password: postgres
32-
driver-class-name: org.postgresql.Driver
27+
url: jdbc:h2:mem:testdb;DB_CLOSE_ON_EXIT=FALSE
28+
username: sa
29+
password: password
30+
driver-class-name: org.h2.Driver
31+
32+
h2:
33+
console:
34+
enabled: true
35+
settings:
36+
trace: true

src/main/resources/archetype-resources/src/main/resources/application.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ server:
1111
idle-timeout: 5000
1212
connection-timeout: 6000
1313
servlet:
14-
context-path: /archetype-example/v1
14+
context-path: /api/v1
1515

1616
# app spring configuration:
1717
spring:
1818
application:
19-
name: archetype-example
19+
name: ${artifactId}
2020
banner:
2121
location: 'classpath:/banner.txt'
2222
main:

0 commit comments

Comments
 (0)