Skip to content

Commit

Permalink
#1 - enable file persistence
Browse files Browse the repository at this point in the history
  • Loading branch information
obriensystems committed Mar 2, 2021
1 parent 3e1eaef commit f6c66b9
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 8 deletions.
12 changes: 10 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<description>Field EventStream</description>
<properties>
<java.version>11</java.version>
<!-- spring-boot.version>2.2.2</spring-boot.version-->
<spring-boot-admin.version>2.3.1</spring-boot-admin.version>
<springfox-version>2.9.2</springfox-version>
</properties>
Expand All @@ -27,10 +28,11 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<!-- spring fox issue -->
<!-- dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
</dependency -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
Expand Down Expand Up @@ -105,6 +107,12 @@
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>
<!-- fix spring fox 2.9.2 issue -->
<!--dependency>
<groupId>org.springframework.plugin</groupId>
<artifactId>spring-plugin-core</artifactId>
<version>1.2.0.RELEASE</version>
</dependency-->
</dependencies>
<dependencyManagement>
<dependencies>
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/systems/eventstream/field/FieldApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ public static void main(String[] args) {
public CommandLineRunner demo(EventRepository repository) {
return (args) -> {
// import rows
repository.save(new Event(System.nanoTime(), "1", "4", "new", "off", "category1"));
// repository.save(new Event(System.nanoTime(), "1", "4", "new", "off", "category1"));
Thread.sleep(1);
repository.save(new Event(System.nanoTime(), "2", "5", "new", "time", "category2"));
// repository.save(new Event(System.nanoTime(), "2", "5", "new", "time", "category2"));
Thread.sleep(1);
repository.save(new Event(System.nanoTime(), "3", "6", "done", "time", "category1"));
// repository.save(new Event(System.nanoTime(), "3", "6", "done", "time", "category1"));

log.info("Events found with findAll():");
log.info("-------------------------------");
Expand All @@ -43,7 +43,9 @@ public CommandLineRunner demo(EventRepository repository) {
Event event = repository.findByKey("2");
log.info("Events found with findByKey(2):");
log.info("--------------------------------");
log.info(event.toString());
if(null != event) {
log.info(event.toString());
}
log.info("");

log.info("Events found with findByCategory('category1'):");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
//import org.springframework.data.rest.core.annotation.RepositoryRestResource;

import systems.eventstream.field.model.Event;

Expand Down
18 changes: 17 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,20 @@ spring.jackson.date-format=systems.eventstream.field.swagger.RFC3339DateFormat
spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false

welcome.message=Event Stream
spring.thymeleaf.cache=false
spring.thymeleaf.cache=false

# override default user sa and empty password
# in memory
#spring.datasource.url=jdbc:h2:mem:testdb
# persistent
spring.datasource.url=jdbc:h2:file:/Users/michaelobrien/ised/field
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.h2.console.enabled=true
spring.h2.console.path=/h2-console
# enable only on first startup
#spring.jpa.hibernate.ddl-auto=create-drop

spring.jpa.show-sql=true

0 comments on commit f6c66b9

Please sign in to comment.