項目目錄概況

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 }
添加項目

