diff --git a/SpringApp/.vscode/launch.json b/SpringApp/.vscode/launch.json index 323cbac..b1e2afa 100644 --- a/SpringApp/.vscode/launch.json +++ b/SpringApp/.vscode/launch.json @@ -7,7 +7,7 @@ "cwd": "${workspaceFolder}", "mainClass": "com.ip.library.LibraryApplication", "projectName": "library", - "args": "", + "args": "--populate", "envFile": "${workspaceFolder}/.env" } ] diff --git a/SpringApp/library/src/main/java/com/ip/library/LibraryApplication.java b/SpringApp/library/src/main/java/com/ip/library/LibraryApplication.java index 0c06483..fe1bcc5 100644 --- a/SpringApp/library/src/main/java/com/ip/library/LibraryApplication.java +++ b/SpringApp/library/src/main/java/com/ip/library/LibraryApplication.java @@ -41,45 +41,26 @@ public class LibraryApplication implements CommandLineRunner { @Override public void run(String... args) throws Exception { - // if (args.length > 0 && args[0].equals("--populate")) { - // log.info("Create default types values"); - // final var type1 = typeService.create(new TypeEntity("type1")); - // final var type2 = typeService.create(new TypeEntity("type2")); + if (args.length > 0 && args[0].equals("--populate")) { + log.info("Create default types values"); + final var type1 = typeService.create(new TypeEntity("type1")); + final var type2 = typeService.create(new TypeEntity("type2")); - // log.info("Create default authors values"); - // final var author1 = authorService.create(new AuthorEntity("author1")); - // final var author2 = authorService.create(new AuthorEntity("author2")); + log.info("Create default authors values"); + final var author1 = authorService.create(new AuthorEntity("author1")); + final var author2 = authorService.create(new AuthorEntity("author2")); - // log.info("Create default books values"); - // final var book1 = bookService.create(new BookEntity("book1", type1, author1)); - // final var book2 = bookService.create(new BookEntity("book2", type1, author2)); - // final var book3 = bookService.create(new BookEntity("book3", type2, author1)); - // final var book4 = bookService.create(new BookEntity("book4", type2, author2)); + log.info("Create default books values"); + final var book1 = bookService.create(new BookEntity("book1", type1, author1)); + final var book2 = bookService.create(new BookEntity("book2", type1, author2)); + final var book3 = bookService.create(new BookEntity("book3", type2, author1)); + final var book4 = bookService.create(new BookEntity("book4", type2, author2)); - // log.info("Create default users values"); - // final var user1 = userService.create(new UserEntity("user1", "123")); - // final var user2 = userService.create(new UserEntity("user2", "123")); - // final var admin1 = userService.create(new UserEntity("admin1", "123")); - // userService.giveAdminRole(admin1.getId()); - // } - log.info("Create default types values"); - final var type1 = typeService.create(new TypeEntity("type1")); - final var type2 = typeService.create(new TypeEntity("type2")); - - log.info("Create default authors values"); - final var author1 = authorService.create(new AuthorEntity("author1")); - final var author2 = authorService.create(new AuthorEntity("author2")); - - log.info("Create default books values"); - final var book1 = bookService.create(new BookEntity("book1", type1, author1)); - final var book2 = bookService.create(new BookEntity("book2", type1, author2)); - final var book3 = bookService.create(new BookEntity("book3", type2, author1)); - final var book4 = bookService.create(new BookEntity("book4", type2, author2)); - - log.info("Create default users values"); - final var user1 = userService.create(new UserEntity("user1", "123")); - final var user2 = userService.create(new UserEntity("user2", "123")); - final var admin1 = userService.create(new UserEntity("admin1", "123")); - userService.giveAdminRole(admin1.getId()); + log.info("Create default users values"); + final var user1 = userService.create(new UserEntity("user1", "123")); + final var user2 = userService.create(new UserEntity("user2", "123")); + final var admin1 = userService.create(new UserEntity("admin1", "123")); + userService.giveAdminRole(admin1.getId()); + } } } diff --git a/SpringApp/library/src/main/resources/application.properties b/SpringApp/library/src/main/resources/application.properties index 8f5373c..5baf834 100644 --- a/SpringApp/library/src/main/resources/application.properties +++ b/SpringApp/library/src/main/resources/application.properties @@ -6,7 +6,7 @@ server.port=8080 # Available levels are: TRACE, DEBUG, INFO, WARN, ERROR, FATAL, OFF logging.level.com.example.demo=DEBUG -# Set default orofile +# Set default profile spring.profiles.default=dev # Common JPA Settings