Can a program depend on a library during compilation but not runtime?

前端 未结 10 1740
深忆病人
深忆病人 2020-11-30 18:18

I understand the difference between runtime and compile-time and how to differentiate between the two, but I just don\'t see the need to make a distinction between compile-t

10条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-30 18:21

    Just ran into an issue that answers your question. servlet-api.jar is a transient dependency in my web project and is needed both at compile time and runtime. But servlet-api.jar is also included in my Tomcat library.

    The solution here is to make servlet-api.jar in maven available only at compile time and not packaged in my war file so that it would not clash with the servlet-api.jar contained in my Tomcat library.

    I hope this explains Compile time and Runtime dependency.

提交回复
热议问题