diff --git a/.gitignore b/.gitignore index 1a05e5d..4a368e9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /.idea -/target \ No newline at end of file +/target +/*.log \ No newline at end of file diff --git a/pom.xml b/pom.xml index d0f5f48..551c138 100644 --- a/pom.xml +++ b/pom.xml @@ -33,6 +33,11 @@ org.springframework.boot spring-boot-starter + + org.springframework.shell + spring-shell-starter + 2.0.0.RELEASE + org.junit.jupiter diff --git a/src/main/java/ru/graff/Main.java b/src/main/java/ru/graff/Main.java index b589c0d..f6c8842 100644 --- a/src/main/java/ru/graff/Main.java +++ b/src/main/java/ru/graff/Main.java @@ -1,16 +1,16 @@ package ru.graff; +import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import ru.graff.service.TestingService; @SpringBootApplication public class Main { public static void main(String[] args) { - AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Main.class); - TestingService testingService = context.getBean(TestingService.class); - testingService.startTest(); + SpringApplication.run(Main.class); +// ApplicationContext context = SpringApplication.run(Main.class, args); +// TestingService testingService = context.getBean(TestingService.class); +// testingService.startTest(); } } diff --git a/src/main/java/ru/graff/dao/TestingDaoSimple.java b/src/main/java/ru/graff/dao/TestingDaoSimple.java index 3ffcd5f..910652c 100644 --- a/src/main/java/ru/graff/dao/TestingDaoSimple.java +++ b/src/main/java/ru/graff/dao/TestingDaoSimple.java @@ -1,7 +1,6 @@ package ru.graff.dao; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.PropertySource; import org.springframework.stereotype.Repository; import ru.graff.domain.Question; @@ -12,7 +11,6 @@ import java.util.List; import java.util.Locale; -@PropertySource("classpath:application.yml") @Repository public class TestingDaoSimple implements TestingDao { diff --git a/src/main/java/ru/graff/service/TestingServiceImpl.java b/src/main/java/ru/graff/service/TestingServiceImpl.java index af13aad..f79b720 100644 --- a/src/main/java/ru/graff/service/TestingServiceImpl.java +++ b/src/main/java/ru/graff/service/TestingServiceImpl.java @@ -2,7 +2,6 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.context.MessageSource; -import org.springframework.context.annotation.PropertySource; import org.springframework.stereotype.Service; import ru.graff.dao.PersonDao; import ru.graff.dao.TestingDao; @@ -11,7 +10,6 @@ import java.util.Locale; import java.util.Scanner; -@PropertySource("classpath:application.yml") @Service public class TestingServiceImpl implements TestingService { @@ -20,7 +18,7 @@ public class TestingServiceImpl implements TestingService { private final PersonDao personDao; private final TestingDao testingDao; - public TestingServiceImpl(@Value("${locale}")String locale, MessageSource messageSource, PersonDao personDao, TestingDao testingDao) { + public TestingServiceImpl(@Value("${application.locale}")String locale, MessageSource messageSource, PersonDao personDao, TestingDao testingDao) { this.messageSource = messageSource; this.personDao = personDao; this.testingDao = testingDao; diff --git a/src/main/java/ru/graff/shell/StartTestCommands.java b/src/main/java/ru/graff/shell/StartTestCommands.java new file mode 100644 index 0000000..9508ce0 --- /dev/null +++ b/src/main/java/ru/graff/shell/StartTestCommands.java @@ -0,0 +1,21 @@ +package ru.graff.shell; + +import org.springframework.shell.standard.ShellComponent; +import org.springframework.shell.standard.ShellMethod; +import ru.graff.service.TestingService; + +@ShellComponent +public class StartTestCommands { + + private final TestingService service; + + public StartTestCommands(TestingService service) { + this.service = service; + } + + @ShellMethod("Translate text from one language to another.") + public void startTest() { + service.startTest(); + } + +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index da7c208..0d2dd2f 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,4 +1,5 @@ -locale: RU -file.path: tests_ru.csv -#locale: EN -#file.path: tests.csv \ No newline at end of file +application: + locale: EN #ENRU + +file: + path: tests.csv #tests_ru.csv \ No newline at end of file