File tree Expand file tree Collapse file tree 16 files changed +312
-0
lines changed
multimodule-maven-project
test/java/com/baeldung/userdao/test Expand file tree Collapse file tree 16 files changed +312
-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+ <parent >
5+ <groupId >com.baeldung.multimodule-maven-project</groupId >
6+ <artifactId >multimodule-maven-project</artifactId >
7+ <version >1.0</version >
8+ </parent >
9+ <groupId >com.baeldung.daomodule</groupId >
10+ <artifactId >daomodule</artifactId >
11+ <packaging >jar</packaging >
12+ <version >1.0</version >
13+ <name >daomodule</name >
14+ </project >
Original file line number Diff line number Diff line change 1+ package com .baeldung .dao ;
2+
3+ import java .util .List ;
4+ import java .util .Optional ;
5+
6+ public interface Dao <T > {
7+
8+ Optional <T > findById (int id );
9+
10+ List <T > findAll ();
11+
12+ }
Original file line number Diff line number Diff line change 1+ module com .baeldung .dao {
2+ exports com .baeldung .dao ;
3+ }
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+ <parent >
5+ <groupId >com.baeldung.multimodule-maven-project</groupId >
6+ <artifactId >multimodule-maven-project</artifactId >
7+ <version >1.0</version >
8+ </parent >
9+ <groupId >com.baeldung.entitymodule</groupId >
10+ <artifactId >entitymodule</artifactId >
11+ <packaging >jar</packaging >
12+ <version >1.0</version >
13+ <name >entitymodule</name >
14+ <properties >
15+ <maven .compiler.source>11</maven .compiler.source>
16+ <maven .compiler.target>11</maven .compiler.target>
17+ </properties >
18+ </project >
Original file line number Diff line number Diff line change 1+ package com .baeldung .entity ;
2+
3+ public class User {
4+
5+ private final String name ;
6+
7+ public User (String name ) {
8+ this .name = name ;
9+ }
10+
11+ public String getName () {
12+ return name ;
13+ }
14+
15+ @ Override
16+ public String toString () {
17+ return "User{" + "name=" + name + '}' ;
18+ }
19+ }
Original file line number Diff line number Diff line change 1+ module com .baeldung .entity {
2+ exports com .baeldung .entity ;
3+ }
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+ <parent >
5+ <groupId >com.baeldung.multimodule-maven-project</groupId >
6+ <artifactId >multimodule-maven-project</artifactId >
7+ <version >1.0</version >
8+ </parent >
9+ <groupId >com.baeldung.mainappmodule</groupId >
10+ <artifactId >mainappmodule</artifactId >
11+ <version >1.0</version >
12+ <packaging >jar</packaging >
13+ <name >mainappmodule</name >
14+
15+ <dependencies >
16+ <dependency >
17+ <groupId >com.baeldung.entitymodule</groupId >
18+ <artifactId >entitymodule</artifactId >
19+ <version >1.0</version >
20+ </dependency >
21+ <dependency >
22+ <groupId >com.baeldung.daomodule</groupId >
23+ <artifactId >daomodule</artifactId >
24+ <version >1.0</version >
25+ </dependency >
26+ <dependency >
27+ <groupId >com.baeldung.userdaomodule</groupId >
28+ <artifactId >userdaomodule</artifactId >
29+ <version >1.0</version >
30+ </dependency >
31+ </dependencies >
32+ </project >
Original file line number Diff line number Diff line change 1+ package com .baeldung .mainapp ;
2+
3+ import com .baeldung .dao .Dao ;
4+ import com .baeldung .entity .User ;
5+ import com .baeldung .userdao .UserDao ;
6+ import java .util .HashMap ;
7+ import java .util .Map ;
8+
9+ public class Application {
10+
11+ public static void main (String [] args ) {
12+ Map <Integer , User > users = new HashMap <>();
13+ users .put (1 , new User ("Julie" ));
14+ users .put (2 , new User ("David" ));
15+ Dao userDao = new UserDao (users );
16+ userDao .findAll ().forEach (System .out ::println );
17+ }
18+
19+ }
Original file line number Diff line number Diff line change 1+ module com .baeldung .mainapp {
2+ requires com .baeldung .entity ;
3+ requires com .baeldung .userdao ;
4+ requires com .baeldung .dao ;
5+ uses com .baeldung .dao .Dao ;
6+ }
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.baeldung.multimodule-maven-project</groupId >
5+ <artifactId >multimodule-maven-project</artifactId >
6+ <version >1.0</version >
7+ <packaging >pom</packaging >
8+ <name >multimodule-maven-project</name >
9+ <parent >
10+ <groupId >com.baeldung.maven-java-11</groupId >
11+ <artifactId >maven-java-11</artifactId >
12+ <version >1.0</version >
13+ </parent >
14+
15+ <dependencyManagement >
16+ <dependencies >
17+ <dependency >
18+ <groupId >junit</groupId >
19+ <artifactId >junit</artifactId >
20+ <version >4.12</version >
21+ <scope >test</scope >
22+ </dependency >
23+ <dependency >
24+ <groupId >org.assertj</groupId >
25+ <artifactId >assertj-core</artifactId >
26+ <version >3.12.2</version >
27+ <scope >test</scope >
28+ </dependency >
29+ </dependencies >
30+ </dependencyManagement >
31+
32+ <build >
33+ <pluginManagement >
34+ <plugins >
35+ <plugin >
36+ <groupId >org.apache.maven.plugins</groupId >
37+ <artifactId >maven-compiler-plugin</artifactId >
38+ <version >3.8.0</version >
39+ <configuration >
40+ <source >11</source >
41+ <target >11</target >
42+ </configuration >
43+ </plugin >
44+ </plugins >
45+ </pluginManagement >
46+ </build >
47+
48+ <modules >
49+ <module >entitymodule</module >
50+ <module >daomodule</module >
51+ <module >userdaomodule</module >
52+ <module >mainappmodule</module >
53+ </modules >
54+
55+ <properties >
56+ <project .build.sourceEncoding>UTF-8</project .build.sourceEncoding>
57+ </properties >
58+ </project >
You can’t perform that action at this time.
0 commit comments