Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ nbbuild/
dist/
nbdist/
.nb-gradle/
/nbproject/
43 changes: 20 additions & 23 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.therealdanvega</groupId>
<artifactId>jsontodb</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>jsontodb</name>
<description>Reading JSON and writing to a DB</description>

<parent>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.4.RELEASE</version>
<version>2.4.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.therealdanvega</groupId>
<artifactId>jsontodb</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>jsontodb</name>
<description>Reading JSON and writing to a DB</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>

Expand All @@ -29,23 +23,19 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator-docs</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<artifactId>spring-boot-starter-hateoas</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
Expand All @@ -68,9 +58,16 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>


</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@RequestMapping("/users")
public class UserController {

private UserService userService;
private final UserService userService;

public UserController(UserService userService) {
this.userService = userService;
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/com/therealdanvega/domain/User.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.therealdanvega.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;

import javax.persistence.*;

@Data
@AllArgsConstructor
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@NoArgsConstructor
@Entity
public class User {

Expand All @@ -24,6 +25,5 @@ public class User {
private Address address;
@Embedded
private Company company;

public User() {}

}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.therealdanvega.repository;

import com.therealdanvega.domain.User;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.jpa.repository.JpaRepository;

public interface UserRepository extends CrudRepository<User, Long> {
public interface UserRepository extends JpaRepository<User, Long> {



Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/therealdanvega/service/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@Service
public class UserService {

private UserRepository userRepository;
private final UserRepository userRepository;

public UserService(UserRepository userRepository) {
this.userRepository = userRepository;
Expand All @@ -24,6 +24,6 @@ public User save(User user) {
}

public void save(List<User> users) {
userRepository.save(users);
userRepository.saveAll(users);
}
}
2 changes: 1 addition & 1 deletion src/main/resources/json/users.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// https://jsonplaceholder.typicode.com/users

[
{
"id": 1,
Expand Down
21 changes: 21 additions & 0 deletions src/test/java/com/therealdanvega/JsontodbApplicationTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.therealdanvega;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

/**
*
* @author AHE
*/

@SpringBootTest
class JsontodbApplicationTest {

public JsontodbApplicationTest() {
}

@Test
void contextLoads() {
}

}
16 changes: 0 additions & 16 deletions src/test/java/com/therealdanvega/JsontodbApplicationTests.java

This file was deleted.