English 中文(简体)
在Maven的“提供”范围内的“选择”扶养
原标题:"optional" dependency with scope "provided" in Maven
  • 时间:2011-05-02 17:39:42
  •  标签:
  • maven
  • log4j

马文有时比我的头部高一点...... 我创建了一个图书馆,可选择依赖高尔夫球和 log球。 选择:

  • My library needs those logging frameworks at compile time
  • My library doesn t need them at runtime, but if it "discovers" them, it will use them

目前,我把依赖称为“选择”和“提供”:

<dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.16</version>
    <type>jar</type>
    <scope>provided</scope>
    <optional>true</optional>
</dependency>

但是,我的一些用户报告了问题,因为他们并不需要记录4 /lf4j。 我的扶养是否正确? 不幸的是,我认为正式文件太抽象,无法理解这一问题。

最佳回答

http://maven.apache.org/guides/introduction/introduction-to-optional-and-ilaes-dependencies.html”rel=“noreferer”>。 它非常好地描述了你的使用情况。 在使用你的图书馆的申请中,标记依赖性作为选择,不会解决作为过境依赖性的问题(即使范围为<代码>compile)。

In difference to <scope>provided</scope> which is used for required dependencies which will be provided by the runtime environment an <optional>true</optional> dependency is not necessarily meant to be required (The idea is that some of the dependencies are only used for certain features in the project, and will not be needed if that feature isn t used.).

如果利用你的图书馆的项目将使用任择附属公司提供的任何功能,项目必须自行宣布这些附属公司。

由于你的配置似乎对我来说是正确的,我不知道发生了什么原因。 或许你们的选择性依赖物会得到其他图书馆的解决,这些图书馆的版本并不期望。 这当然会造成问题。

问题回答

暂无回答




相关问题
Specify time zone of log4j s date

Is it possible to specify the time zone that log4j will use? I need the dates in the log file to be a different time zone than the application s. log4j s PatternLayout uses SimpleDateFormat. ...

java wrapper around log4j logger and java.util.logging

I am writing a library. The library can be used by applications that use log4j loggers and java.util.logging loggers. So, I wrote a quick wrapper class, that encapsulates both loggers. I allow the ...

Grails log4j configuration

I ve repeatedly had problems with the DSL introduced by Grails in version 1.1 for configuring Log4J. My current configuration looks like this: log4j = { debug com.mypackages ...

Creating daily logs with Log4j?

What configuration values are needed to setup Log4j to use the following pattern? MyApp-Mon.log MyApp-Tue.log MyApp-Wed.log Etc With each file containing the days log. This sounds easy enough to do ...

Overriding log4j settings at deploy time

For an application which is deployed on a large number of machines I took the decision to deploy a standard log4j.xml file with the application package, just to make sure that have the same settings ...

How to validate Java logging properties files?

I have a basic facility for allowing users to remotely apply changes to the logging files in my application. Some logs are configured using java.util.logging properties files, and some are configured ...

How do you Change a Package s Log Level using Log4j?

I ve encountered the following bug: http://issues.apache.org/jira/browse/AXIS2-4363 It states the following: This error only occurs when log level for org.apache.axiom is DEBUG so a ...

热门标签