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
11 changes: 10 additions & 1 deletion Drafts/Weather2/Weather2.iml
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4" />
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
22 changes: 22 additions & 0 deletions GuessNumber/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?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>

<groupId>groupId</groupId>
<artifactId>GuessNumber</artifactId>
<version>1.0-SNAPSHOT</version>

<dependencies>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.2.8.RELEASE</version>
</dependency>

</dependencies>


</project>
3 changes: 0 additions & 3 deletions GuessNumber/src/GuessSource.java

This file was deleted.

20 changes: 0 additions & 20 deletions GuessNumber/src/Main.java

This file was deleted.

25 changes: 25 additions & 0 deletions GuessNumber/src/main/java/ApplicationConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration
@ComponentScan
public class ApplicationConfig {

@Bean
public KeyboardGuess getkeyboardGuess() {
return new KeyboardGuess();
}

@Bean
public ConsoleOutput getconsoleOutput() {
return new ConsoleOutput();
}

@Bean
public GuessNumberGame getguessNumberGame(KeyboardGuess keyboardGuess, ConsoleOutput consoleOutput) {
return new GuessNumberGame(15, 3, keyboardGuess, consoleOutput);
}


}
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import org.springframework.stereotype.Component;

@Component
public class ConsoleOutput implements ResultOutput {

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

public class GuessNumberGame {

private int secretNumber;
Expand Down
6 changes: 6 additions & 0 deletions GuessNumber/src/main/java/GuessSource.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import org.springframework.stereotype.Component;

@Component
public interface GuessSource {
public int guess();
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import org.springframework.stereotype.Component;

import java.util.Scanner;

@Component
public class KeyboardGuess implements GuessSource {
Scanner scanner = new Scanner(System.in);
@Override
Expand Down
35 changes: 35 additions & 0 deletions GuessNumber/src/main/java/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.ProxyAsyncConfiguration;

public class Main {
// авг 30, 2020 1:29:53 AM org.springframework.context.support.AbstractApplicationContext refresh
// WARNING: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.context.annotation.internalAsyncAnnotationProcessor' defined in class path resource [org/springframework/scheduling/annotation/ProxyAsyncConfiguration .class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.scheduling.annotation.AsyncAnnotationBeanPostProcessor]: Factory method 'asyncAdvisor' threw exception; nested exception is java.lang.IllegalArgumentException: @EnableAsync
// annotation metadata was not injected
// Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.context.annotation.internalAsyncAnnotationProcessor' defined in class path resource [org/springframework/scheduling/annotation/ProxyAsyncConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.scheduling.annotation.AsyncAnnotationBeanPostProcessor]: Factory method 'asyncAdvisor' threw exception; nested exception is java.lang.IllegalArgumentException: @EnableAsync annotation metadata was not injected


public static void main(String[] args) {
// ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
ApplicationContext context = new AnnotationConfigApplicationContext(ApplicationConfig.class);

// KeyboardGuess source = new KeyboardGuess();
// ConsoleOutput output = new ConsoleOutput();
// int secretNumber = 15;
// int attemptsCount = 3;
//
// GuessNumberGame game = new GuessNumberGame(
// secretNumber,
// attemptsCount,
// source,
// output);
GuessNumberGame game = context.getBean("guessNumberGame", GuessNumberGame.class);

game.play();
}


}
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import org.springframework.stereotype.Component;

@Component
public interface ResultOutput {
public void output(String result);
}
13 changes: 13 additions & 0 deletions GuessNumber/src/main/resources/beans.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">


<context:component-scan base-package=""></context:component-scan>

</beans>