Modular exploration of Java projects

Modularity is a new feature module system of Java9: a module is a container of packages, and one of the biggest changes in Java 9 is the introduction of a module system (Jigsaw project).

Insert picture description here
Insert picture description here

module a1 {
    
    
    exports Car;
    requires kotlin.stdlib;
}
package Car;

public class Car {
    
    

    public String get() {
    
    

        System.out.println("这里是被调用模块");
        return "Car";
    }
}

module application {
    
    
    requires a1;

}
package com.fancv;

import Car.Car;

public class ApplicationStart {
    
    
    public static void main(String[] args) {
    
    
        System.out.println("启动应用");

        Car c = new Car();

        c.get();
    }
}

The Java source code in Java9 has been divided into modules. I personally understand that modularization is a method or tool for code management.
The Java source code to be loaded can be selected more flexibly during packaging.

In addition, the jvm virtual machine also supports modular compilation, two different concepts.

Some people hold the view: Java modularity is similar to maven, and personally agree with the management of project modules.
Looking at the interview questions on the Internet, there are few in-depth investigations on Java 9 modularity.
In the attempt to modularize in the maven project, the structural idea tool directly ignores the choice of modules. It can be seen that Java modularity and maven are basically in a competitive relationship.
Can you talk about whether Java modularity will replace maven or greadel in the future?

The industry generally uses maven to manage jar packages, and projects are dependent on them, and there is no economic motivation for modular transformation.

As for reducing jar size, the cost of hard disk and memory is already very low in the era of cloud computing. Large-scale distributed projects will consider that for most projects, the benefits are not large. In addition, Java modularization can use kotlin hybrid programming. This has value for some specific scenarios, but the base of kotlin practitioners is too low and the personnel risk is high.

The above is the exploration and thinking of the new features of Java9 modularization.

参考资料:
1.https://blog.csdn.net/u010398771/article/details/100117986
2.https://blog.csdn.net/zebe1989/article/details/82692570?utm_medium=distribute.pc_relevant.none-task-blog-OPENSEARCH-3.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-OPENSEARCH-3.control
3.https://blog.csdn.net/qq_41962328/article/details/104541269
4.https://gitchat.blog.csdn.net/article/details/85178887?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-2.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-2.control
5.https://blog.csdn.net/newbieLCQ/article/details/108889242

Guess you like

Origin blog.csdn.net/keep_learn/article/details/112189774
Recommended