项目目录概况

Demo01项目
Test01.java
1 package com.sam.demo01;
2
3 public class Test01 {
4 public void ShowTest01() {
5 System.out.println("我是Test01");
6 }
7 }
Test02.java
1 package com.sam.demo01;
2
3 public class Test02 {
4 public void ShowTest02() {
5 System.out.println("我是Test02");
6 }
7 }
Module-info.java
1 module Demo01 {
2 //如何有其他模块依赖我,那么其他模块下面的1个包都可以访问
3 exports com.sam.demo01;
4 }
Demo02项目
Module-info.java
1 module Demo02 {
2 //如何有其他模块依赖我,那么其他模块下面的1个包可以访问
3 exports com.sam.demo02;
4 //我需要依赖Demo01模块,才能完成我的工作
5 requires Demo01;
6 }
TestMain.java
1 package com.sam.demo02;
2
3 import com.sam.demo01.Test01;
4
5 public class TestMain {
6 public static void main(String[] args) {
7 Test01 test=new Test01();
8 test.ShowTest01();
9 }
10 }
添加项目
