我的servlet应用程序包含许多库.jars,其中一些包含嵌入的log4j.xml或log4j.properties文件.我想确保log4j首先找到我的log4j.xml!我已经尝试在servlet中搜索各种类路径元素的优先级的一些规范(例如,WEB-INF/classes总是在WEB-INF/lib之前吗?),或者某种方式来配置或调整servlet的类加载器,以便给定的资源目录出现在类路径的早期.到目前为止,我已经画了一个空白.有关确保servlet .war文件通过类加载器加载正确的log4j.xml的任何建议吗?
我编写了一个利用JAXB进行XSL转换的java应用程序.我在我的类路径中包含了saxon9.jar,因此我可以在命令行上使用XSLT 2.0而不是XSLT 1.0.
java -classpath ./lib/saxon9.jar:./ -jar myApp.jar
Run Code Online (Sandbox Code Playgroud)
我在XSL中包含了代码来报告使用的XSLT.
<xsl:comment><xsl:text >
</xsl:text>XSLT Version: <xsl:value-of select="system-property('xsl:version')" /> <xsl:text >
</xsl:text>XSLT Vendor: <xsl:value-of select="system-property('xsl:vendor')" /> <xsl:text >
</xsl:text>XSLT Vendor URL: <xsl:value-of select="system-property('xsl:vendor-url')" /> <xsl:text >
</xsl:text></xsl:comment>
Run Code Online (Sandbox Code Playgroud)
它报道.
XSLT Version: 1.0
XSLT Vendor: Apache Software Foundation (Xalan XSLTC)
XSLT Vendor URL: http://xml.apache.org/xalan-j
Run Code Online (Sandbox Code Playgroud)
这是JVM的默认实现.
如何使用我指定的Saxon?
跟进:
所以这些方法都不起作用(除了将撒克逊jar放在背书目录中),但它们都应该有效.看来我使用"-jar myApp.jar"和想要替代XSLT实现的组合是不兼容的.换一种说法...
java -Djavax.xml.transform.TransformerFactory = net.sf.saxon.TransformerFactoryImpl -classpath ./lib/saxon9.jar:./ -jar myApp.jar
......不起作用,但这确实......
java -Djavax.xml.transform.TransformerFactory = net.sf.saxon.TransformerFactoryImpl -classpath ./lib/saxon9.jar:./myApp.jar org.dacracot.myApp
...有趣的是,我甚至不必指定工厂,我得到了撒克逊版本......
java -classpath ./lib/saxon9.jar:./myApp.jar org.dacracot.myApp
示例:
对于日志记录,我的代码使用log4j.但我的代码依赖的其他罐子,slf4j而是使用.因此两个罐子必须在构建路径中.不幸的是,我的代码slf4j现在可以通过上下文辅助或其他一些开发人员更改直接使用(依赖).我想任何使用slf4j显示为错误,但我的应用程序(和测试)在运行时仍然需要在类路径中.
解释:
我想知道这是否可能在eclipse中.这种情况经常发生在我身上.我将有一个大型项目,它使用了很多第三方库.当然,这些第三方罐子也有自己的依赖关系.因此,我必须在类路径(eclipse中的"构建路径")中包含所有依赖项,以便应用程序及其测试进行编译和运行(从eclipse中).
但我不希望我的代码使用所有这些jar,只是我自己决定的几个直接依赖.因此,如果我的代码意外地使用了依赖项的依赖项,我希望它显示为编译错误.理想情况下,没有找到类,但任何错误都可以.
我知道我可以在eclipse之外运行时手动配置类路径,甚至在eclipse中我可以修改我正在运行的特定类的类路径(在运行配置中),但是如果你运行了很多单独的测试用例,这是不可管理的,或者有很多main()类.
自Java 1.5以来,javac一直在寻找第三方罐子的清单来寻找其他罐子.这会导致许多不良副作用:
-Xlint:-path)所以我想知道是否有人知道魔术调用来禁用它.假设Sun没有给我们带来另一个我们不想要的功能,一旦我们拥有它就无法关闭.
def mergedCompileClasspath == null
project.sourceSets.each {
if (mergedCompileClasspath == null)
mergedCompileClasspath = it.compileClasspath
else
mergedCompileClasspath .plus(it.compileClasspath)
}
Run Code Online (Sandbox Code Playgroud)
plus() 方法不起作用。compileClassPath 是不可变的?如何创建一个空的fileCollection?
有没有办法获取 Kotlin 中“资源”文件夹中所有文件的列表?
我可以将特定文件读取为
Application::class.java.getResourceAsStream("/folder/filename.ext")
Run Code Online (Sandbox Code Playgroud)
但有时我只想将文件夹“文件夹”中的所有内容提取到外部目录。
谢谢你。
首先,我也见过类似的问题。另一个问题链接 但我认为它的答案不是很清楚。
\n\n我的一些问题如下\xef\xbc\x9a
\n\n\xef\xbc\x881\xef\xbc\x89 --jars 参数 与spark.executor.extraClassPath 参数相同,如果不同,有什么区别?
\n\n我检查了spark-submit命令行中的--jars上的--help,解释如下:
\n\n Comma-separated list of local jars to include on the driver\n and executor classpaths.\nRun Code Online (Sandbox Code Playgroud)\n\n但是,我在spark-submit命令行中没有找到spark.executor.extraClassPath的解释。最后在spark官网找到了如下关于spark.executor.extraClassPath的解释:
\n\nExtra classpath entries to prepend to the classpath of executors. \nRun Code Online (Sandbox Code Playgroud)\n\n从两个\xef\xbc\x9f的解释来看貌似效果一样
\n\n但我从另一个问题链接中看到以下段落:
\n\n\n\n\n--jars 与 SparkContext.addJar:这些是相同的,只有一个是通过 Spark 提交设置的,另一个是通过代码设置的。选择更适合您的一款。需要注意的一件重要事情是,使用这两个选项中的任何一个都不会将 JAR 添加到驱动程序/执行程序类路径中,您需要使用这两个选项上的 extraClassPath 配置显式添加它们。
\n
怎么又这样了?
\n\n\xef\xbc\x882\xef\xbc\x89spark.executor.extraClassPath 和spark.executor.extraLibraryPath,与spark.driver.extraXXXXpath 相同,前缀相同\xe3\x80\x82
\n\nextraClassPath 和 extraLibraryPath 有什么区别?
\n\nSpark.executor.extraLibraryPath的解释来自spark官网\xe3\x80\x82
\n\nSet a special library path to use when launching …Run Code Online (Sandbox Code Playgroud) 我是 Spring Boot 的新手,目前正在建立一个项目。当我运行应用程序时,它运行良好,但在控制台中我不确定。你们能帮帮我吗。谢谢
The Class-Path manifest attribute in /Users/user/.m2/repository/com/sun/xml/bind/jaxb-impl/2.3.2/jaxb-impl-2.3.2.jar referenced one or more files that do not exist: file:/Users/user/.m2/repository/com/sun/xml/bind/jaxb-impl/2.3.2/jaxb-runtime-2.3.2.jar,file:/Users/user/.m2/repository/com/sun/xml/bind/jaxb-impl/2.3.2/txw2-2.3.2.jar,file:/Users/user/.m2/repository/com/sun/xml/bind/jaxb-impl/2.3.2/istack-commons-runtime-3.0.8.jar,file:/Users/user/.m2/repository/com/sun/xml/bind/jaxb-impl/2.3.2/stax-ex-1.8.1.jar,file:/Users/user/.m2/repository/com/sun/xml/bind/jaxb-impl/2.3.2/FastInfoset-1.2.16.jar,file:/Users/user/.m2/repository/com/sun/xml/bind/jaxb-impl/2.3.2/jakarta.activation-api-1.2.1.jar
The Class-Path manifest attribute in /Users/user/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.1/jaxb-runtime-2.3.1.jar referenced one or more files that do not exist: file:/Users/user/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.1/jaxb-api-2.3.1.jar,file:/Users/user/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.1/txw2-2.3.1.jar,file:/Users/user/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.1/istack-commons-runtime-3.0.7.jar,file:/Users/user/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.1/stax-ex-1.8.jar,file:/Users/user/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.1/FastInfoset-1.2.15.jar,file:/Users/user/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.1/javax.activation-api-1.2.0.jar
Run Code Online (Sandbox Code Playgroud) 我正在构建一个 Java 应用程序,目的是将来将其打包为 Windows 可执行文件。我的 NetBeans 项目结构可以在这里看到 。 我目前正在使用 getResourceAsStream() 读取 config.properties。我不知道不能以类似的方式写入该文件。有人能建议一种实现此目标的方法吗?或者是否需要采用不同的方法来解决我的问题?谢谢。
我安装了 Android Studio 4.1。我收到“构建失败”错误。
PKIX 路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到请求目标的有效认证路径
我曾尝试更改 Gradle 版本和 Gradle 插件版本,以及 Java(8 和 11),但它不起作用。
由于限制了 30000 个字符,所以我把它完整地发布在 google doc 中。 谷歌文档中的完整错误
详细错误是:
A problem occurred configuring root project 'First'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not resolve com.google.flatbuffers:flatbuffers-java:1.12.0.
Required by:
project : > com.android.tools.build:gradle:4.2.0-alpha14
> Could not resolve com.google.flatbuffers:flatbuffers-java:1.12.0.
> Could not get resource 'https://jcenter.bintray.com/com/google/flatbuffers/flatbuffers-java/1.12.0/flatbuffers-java-1.12.0.pom'.
> Could not GET 'https://jcenter.bintray.com/com/google/flatbuffers/flatbuffers-java/1.12.0/flatbuffers-java-1.12.0.pom'.
> PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target …Run Code Online (Sandbox Code Playgroud)