Scenario: When adding logs, the project does not reference the FastJSON package. Later, it is found that the project already references the FastJSON package, but it is not referenced in the module, so it looks at the dependency that references the FastJSON package and finds the Runtime

< the dependency > < groupId > com. Alibaba < / groupId > < artifactId > fastjson < / artifactId > < version > 1.2.3 < / version > <scope>runtime</scope> </dependency>Copy the code

In general, scope is rarely used, but this is unusual. It is found that runtime is actually compiled at runtime. If it is not compiled at runtime, it will not be compiled.

The JDBC driver uses reflection Class. ForName to execute the JDBC driver. If the program does not run, compiling the JDBC driver will not be useful. For example, it will affect the compilation time of the program, but it requires the relevant code to be compiled into the class file at runtime each time, so it will increase the overhead of the runtime program, and is not used for classes that are not dynamically generated.

Fastjson source code does not cover dynamically generated code, such as using reflection, dynamic proxy. So using runtime in a project is not correct.