File tree Expand file tree Collapse file tree 4 files changed +88
-0
lines changed
src/main/java/com/carmelo/ioc Expand file tree Collapse file tree 4 files changed +88
-0
lines changed Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <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" >
3+ <modelVersion >4.0.0</modelVersion >
4+ <groupId >com.carmelo</groupId >
5+ <artifactId >ioc</artifactId >
6+ <version >1.0-SNAPSHOT</version >
7+ <packaging >jar</packaging >
8+
9+ <dependencies >
10+ <dependency >
11+ <groupId >org.springframework</groupId >
12+ <artifactId >spring-context</artifactId >
13+ <version >4.2.4.RELEASE</version >
14+ </dependency >
15+ </dependencies >
16+
17+ <properties >
18+ <project .build.sourceEncoding>UTF-8</project .build.sourceEncoding>
19+ <maven .compiler.source>1.8</maven .compiler.source>
20+ <maven .compiler.target>1.8</maven .compiler.target>
21+ </properties >
22+
23+ </project >
Original file line number Diff line number Diff line change 1+ /*
2+ * To change this license header, choose License Headers in Project Properties.
3+ * To change this template file, choose Tools | Templates
4+ * and open the template in the editor.
5+ */
6+ package com .carmelo .ioc ;
7+
8+ import org .springframework .context .annotation .AnnotationConfigApplicationContext ;
9+ import org .springframework .context .annotation .Bean ;
10+
11+ /**
12+ *
13+ * @author Carmelo Marin Abrego
14+ */
15+ public class Hello {
16+
17+ @ Bean
18+ public HelloService helloBean () {
19+ return new HelloServiceImpl ();
20+ }
21+
22+ public static void main (String [] args ) {
23+ AnnotationConfigApplicationContext applicationContext
24+ = new AnnotationConfigApplicationContext (Hello .class );
25+
26+ HelloService hs = applicationContext .getBean (HelloService .class );
27+
28+ System .out .println (hs .saludar ());
29+ }
30+
31+ }
Original file line number Diff line number Diff line change 1+ /*
2+ * To change this license header, choose License Headers in Project Properties.
3+ * To change this template file, choose Tools | Templates
4+ * and open the template in the editor.
5+ */
6+ package com .carmelo .ioc ;
7+
8+ /**
9+ *
10+ * @author Carmelo Marin Abrego
11+ */
12+ public interface HelloService {
13+ public String saludar ();
14+ }
Original file line number Diff line number Diff line change 1+ /*
2+ * To change this license header, choose License Headers in Project Properties.
3+ * To change this template file, choose Tools | Templates
4+ * and open the template in the editor.
5+ */
6+ package com .carmelo .ioc ;
7+
8+
9+ /**
10+ *
11+ * @author Carmelo Marin Abrego
12+ */
13+ public class HelloServiceImpl implements HelloService {
14+
15+ @ Override
16+ public String saludar () {
17+ return "Hola Mundo." ;
18+ }
19+
20+ }
You can’t perform that action at this time.
0 commit comments