Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* Ver cómo se crean todas las dependencias de las tres formas
  • Loading branch information
Awes0meM4n committed Mar 12, 2020
1 parent 89ff427 commit 90bae09
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Expand Up @@ -19,4 +19,6 @@ Después se siguieron los siguiente pasos:

1. Cambiando paquete base para escanear
* Ya no se sobreescribe. No detecta fuera del paquete base
1. Desambiguar varias beans por identificador
1. Desambiguar varias beans por identificador
1. `@Bean` en `@Configuration`
* Ver cómo se crean todas las dependencias de las tres formas
Expand Up @@ -21,7 +21,8 @@ public static void main(String[] args) {

// test = context.getBean(Test.class);
// test = context.getBean("test", Test.class);
test = context.getBean("anotacion", Test.class);
// test = context.getBean("anotacion", Test.class);
test = context.getBean("config", Test.class);
test.init();

context.close();
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/es/lanyu/datosdeportivosapi/JavaConfig.java
@@ -0,0 +1,25 @@
package es.lanyu.datosdeportivosapi;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class JavaConfig {

@Bean(name="config")
public Test miTest() {
Test test = new Test() {
int llamadas = 0;

@Override
public void init() {
System.out.printf("Llamado %s veces", ++llamadas);
System.out.println();
}

};
test.init();

return test;
}
}

0 comments on commit 90bae09

Please sign in to comment.