maven范围compile与provided何时将工件构建为JAR 之间有什么区别?如果它是WAR,我明白 - 工件将包含在WEB-INF/lib中或不包含在WEB-INF/lib中.但是在JAR的情况下它并不重要 - 不包括依赖性.当它们的范围是compile或时,它们必须在类路径上provided.我知道provided依赖关系不是传递性的 - 但它只是一个区别吗?
我理解运行时和编译时之间的区别以及如何区分这两者,但我没有看到需要区分编译时和运行时依赖.
我正在窒息的是:程序如何在编译期间不依赖运行时依赖的东西?如果我的Java应用程序使用log4j,那么它需要log4j.jar文件才能编译(我的代码集成并调用log4j内部的成员方法)以及运行时(我的代码完全无法控制log4j中的代码后发生的事情) .jar跑了).
我正在阅读依赖解析工具,如Ivy和Maven,这些工具清楚地区分了这两种类型的依赖关系.我只是不明白它的必要性.
任何人都可以给出一个简单的,"国王的英语"式的解释,最好有一个实际的例子,即使像我这样的可怜的人也能理解?
我正在使用intellij和我的代码使用
import javax.xml.bind.annotation.XmlRootElement;
它在我使用命令行时编译并运行.但是,当尝试使用ide(intellij)运行测试类时,它会给出错误
package javax.xml.bind.annotation does not exists
我在我的pom.xml中添加了jaxb依赖项
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
什么力量intellij不发现这个?
我正在尝试运行无法访问 H2 数据库的 Spring Boot 应用程序
spring.datasource.initialization-mode=embedded
spring.datasource.url=jdbc:h2:mem:bitsapi;MODE=Oracle;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
spring.datasource.username=sa
spring.datasource.password=
Run Code Online (Sandbox Code Playgroud)
这些是我如何添加依赖项的 pom.xml
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>2.7.9</version>
<scope>compile</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
当我运行应用程序时,无法绑定属性
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-03-13 12:01:39,685 [main] ERROR o.s.b.d.LoggingFailureAnalysisReporter
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to bind properties under '' to com.zaxxer.hikari.HikariDataSource:
Property: driverclassname
Value: org.h2.Driver
Origin: "driverClassName" from property source "source"
Reason: Failed to load driver class org.h2.Driver in either of HikariConfig class loader …Run Code Online (Sandbox Code Playgroud) 我从网上下载了一些代码并在 Eclipse 中打开它。问题是我的 Eclipse 说
导入org.h2无法解析
对于以下代码:
import org.h2.tools.Server;
Run Code Online (Sandbox Code Playgroud)
我正在学习 Java,那是一个示例代码。我使用的是jdk1.8.0_40。我清理了我的项目,但它仍然存在!