Skip to content

Commit

Permalink
add base structure and update main README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
artem.kobyakov committed Nov 6, 2023
1 parent 1a0b3d5 commit 9ca3438
Show file tree
Hide file tree
Showing 9 changed files with 161 additions and 1 deletion.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@

### Структура репозитория:

- hw01 - директория первого домашнего задания
- hw01 - директория первого домашнего задания (Spring context, xml context configuration)
- hw02 - директория второго домашнего задания (Spring stereotype configuration)
- hw03 - директория третьего домашнего задания (Localization, Mockito)
- hw04 - директория четвертого домашнего задания (Spring shell, @SpringBootTest)
- hw05 - директория пятого домашнего задания (Spring shell, Spring jdbc, H2)
94 changes: 94 additions & 0 deletions hw05/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?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">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.2</version>
<relativePath/>
</parent>

<groupId>ru.otus</groupId>
<artifactId>hw05</artifactId>
<version>1.0</version>

<properties>
<java.version>17</java.version>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<h2.version>2.2.220</h2.version>
<spring.shell.version>3.1.3</spring.shell.version>
<checkstyle-plugin.version>3.2.2</checkstyle-plugin.version>
<checkstyle.version>10.11.0</checkstyle.version>
<checkstyle.config.url>
https://raw.githubusercontent.com/OtusTeam/Spring/master/checkstyle.xml
</checkstyle.config.url>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jdbc</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell-starter</artifactId>
<version>${spring.shell.version}</version>
</dependency>

<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>${h2.version}</version>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle-plugin.version}</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>${checkstyle.version}</version>
</dependency>
</dependencies>
<configuration>
<configLocation>${checkstyle.config.url}</configLocation>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>
14 changes: 14 additions & 0 deletions hw05/src/main/java/ru/otus/library/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package ru.otus.library;

import org.h2.tools.Console;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;


@SpringBootApplication
public class Main {

public static void main(String[] args) throws Exception {
SpringApplication.run(Main.class, args);
}
}
4 changes: 4 additions & 0 deletions hw05/src/main/java/ru/otus/library/entity/Author.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package ru.otus.library.entity;

public class Author {
}
5 changes: 5 additions & 0 deletions hw05/src/main/java/ru/otus/library/entity/Book.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package ru.otus.library.entity;


public class Book {
}
4 changes: 4 additions & 0 deletions hw05/src/main/java/ru/otus/library/entity/Genre.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package ru.otus.library.entity;

public class Genre {
}
18 changes: 18 additions & 0 deletions hw05/src/main/java/ru/otus/library/shell/ApplicationRunner.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package ru.otus.library.shell;

import org.h2.tools.Console;
import org.springframework.shell.standard.ShellComponent;
import org.springframework.shell.standard.ShellMethod;
import org.springframework.shell.standard.ShellMethodAvailability;

import java.sql.SQLException;

@ShellComponent
public class ApplicationRunner {

@ShellMethod(value = "Run test command", key = {"r", "run"})
// @ShellMethodAvailability(value = "wasPermissionGot")
public void runApplication() throws Exception {
Console.main();
}
}
16 changes: 16 additions & 0 deletions hw05/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
spring:
datasource:
url: jdbc:h2:mem:testdb
#initialization-mode: always
#schema: schema.sql
#data: data.sql
# sql:
# init:
# mode: always
# data-locations: data.sql
# schema-locations: schema.sql
h2:
console:
path: /h2-console
settings:
web-allow-others: true
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
<module>hw02</module>
<module>hw03</module>
<module>hw04</module>
<module>hw05</module>
</modules>
</project>

0 comments on commit 9ca3438

Please sign in to comment.