Skip to content

Commit 582bb8a

Browse files
authored
Merge pull request eugenp#6289 from eugenp/BAEL-2399
BAEL-2399: Migrate Spring DI example to spring-core module
2 parents 874acdd + 01fa4cf commit 582bb8a

File tree

26 files changed

+129
-78
lines changed

26 files changed

+129
-78
lines changed

core-java-collections/src/test/java/com/baeldung/queueInterface/PriorityQueueUnitTest.java renamed to core-java-collections/src/test/java/com/baeldung/queueinterface/PriorityQueueUnitTest.java

File renamed without changes.

guice/pom.xml

Lines changed: 24 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,29 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0"
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5-
<modelVersion>4.0.0</modelVersion>
6-
<groupId>com.baeldung.examples.guice</groupId>
7-
<artifactId>guice</artifactId>
8-
<version>1.0-SNAPSHOT</version>
9-
<packaging>jar</packaging>
10-
<name>guice</name>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>com.baeldung.examples.guice</groupId>
6+
<artifactId>guice</artifactId>
7+
<version>1.0-SNAPSHOT</version>
8+
<packaging>jar</packaging>
9+
<name>guice</name>
1110

12-
<parent>
13-
<groupId>com.baeldung</groupId>
14-
<artifactId>parent-modules</artifactId>
15-
<version>1.0.0-SNAPSHOT</version>
16-
</parent>
11+
<parent>
12+
<groupId>com.baeldung</groupId>
13+
<artifactId>parent-modules</artifactId>
14+
<version>1.0.0-SNAPSHOT</version>
15+
</parent>
1716

18-
<dependencies>
19-
<dependency>
20-
<groupId>com.google.inject</groupId>
21-
<artifactId>guice</artifactId>
22-
<version>${guice.version}</version>
23-
</dependency>
17+
<dependencies>
18+
<dependency>
19+
<groupId>com.google.inject</groupId>
20+
<artifactId>guice</artifactId>
21+
<version>${guice.version}</version>
22+
</dependency>
23+
</dependencies>
2424

25-
<dependency>
26-
<groupId>org.springframework</groupId>
27-
<artifactId>spring-context</artifactId>
28-
<version>${spring.version}</version>
29-
</dependency>
25+
<properties>
26+
<guice.version>4.1.0</guice.version>
27+
</properties>
3028

31-
<dependency>
32-
<groupId>org.springframework</groupId>
33-
<artifactId>spring-test</artifactId>
34-
<version>${springtest.version}</version>
35-
<scope>test</scope>
36-
</dependency>
37-
</dependencies>
38-
39-
<properties>
40-
<guice.version>4.2.2</guice.version>
41-
<spring.version>5.1.3.RELEASE</spring.version>
42-
<springtest.version>5.1.3.RELEASE</springtest.version>
43-
</properties>
44-
45-
</project>
29+
</project>

guice/src/main/java/com/baeldung/examples/common/Account.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package com.baeldung.examples.common;
22

3-
import org.springframework.stereotype.Component;
4-
5-
@Component
63
public class Account {
74

85
private String accountNumber;
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package com.baeldung.examples.common;
22

3-
import org.springframework.stereotype.Component;
4-
5-
@Component
63
public class AccountServiceImpl implements AccountService {
74

85
}
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
package com.baeldung.examples.common;
22

3-
import org.springframework.beans.factory.annotation.Autowired;
4-
53
public class BookServiceImpl implements BookService {
64

7-
@Autowired(required = false)
85
private AuthorService authorService;
96

107
}
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package com.baeldung.examples.common;
22

3-
import org.springframework.stereotype.Component;
4-
5-
@Component
63
public class PersonDaoImpl implements PersonDao {
74

85
}
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
package com.baeldung.examples.guice;
22

3-
import org.springframework.lang.Nullable;
4-
53
import com.google.inject.Inject;
64

75
public class FooProcessor {
86

97
@Inject
10-
@Nullable
118
private Foo foo;
129
}

guice/src/main/java/com/baeldung/examples/guice/modules/GuiceModule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ protected void configure() {
2727
// });
2828
bind(Foo.class).toProvider(new Provider<Foo>() {
2929
public Foo get() {
30-
return null;
30+
return new Foo();
3131
}
3232
});
3333
bind(PersonDao.class).to(PersonDaoImpl.class);
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.baeldung.di.spring;
2+
3+
import org.springframework.stereotype.Component;
4+
5+
@Component
6+
public class Account {
7+
8+
private String accountNumber;
9+
private String type;
10+
11+
public String getAccountNumber() {
12+
return accountNumber;
13+
}
14+
15+
public void setAccountNumber(String accountNumber) {
16+
this.accountNumber = accountNumber;
17+
}
18+
19+
public String getType() {
20+
return type;
21+
}
22+
23+
public void setType(String type) {
24+
this.type = type;
25+
}
26+
27+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.baeldung.di.spring;
2+
3+
public interface AccountService {
4+
5+
}

0 commit comments

Comments
 (0)