我正在制作一个使用sparql端点服务的maven应用程序.我想有一个maven目标来下载sparql端点并启动服务,但似乎maven在配置类路径时遇到一些问题.
我在https://mvnrepository.com/artifact/com.blazegraph/bigdata-jar上使用了blazegraph及其工件.
这是我在pom.xml中的插件配置:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.bigdata.rdf.sail.webapp.StandaloneNanoSparqlServer</mainClass>
<includePluginDependencies>true</includePluginDependencies>
<includeProjectDependencies>false</includeProjectDependencies>
<executableDependency>
<groupId>com.blazegraph</groupId>
<artifactId>blazegraph-jar</artifactId>
</executableDependency>
<addOutputToClasspath>false</addOutputToClasspath>
</configuration>
<dependencies>
<!-- https://mvnrepository.com/artifact/com.blazegraph/blazegraph-jar -->
<dependency>
<groupId>com.blazegraph</groupId>
<artifactId>blazegraph-jar</artifactId>
<version>2.1.4</version>
<scope>runtime</scope>
<type>jar</type>
</dependency>
</dependencies>
</plugin>
Run Code Online (Sandbox Code Playgroud)
调试输出提示插件无法找到工件:
Caused by: java.lang.NullPointerException
at org.codehaus.mojo.exec.AbstractExecMojo.findExecutableArtifact(AbstractExecMojo.java:278)
at org.codehaus.mojo.exec.ExecJavaMojo.determineRelevantPluginDependencies(ExecJavaMojo.java:650)
at org.codehaus.mojo.exec.ExecJavaMojo.addRelevantPluginDependenciesToClasspath(ExecJavaMojo.java:568)
at org.codehaus.mojo.exec.ExecJavaMojo.getClassLoader(ExecJavaMojo.java:520)
at org.codehaus.mojo.exec.ExecJavaMojo.execute(ExecJavaMojo.java:301)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
... 27 more
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
编辑1 这个问题不是什么是NullPointerException的副本,我该如何解决?因为Maven抛出异常,因为它无法在依赖项列表中找到正确的工件(但它应该).
编辑2 感谢@Sean Patrick Floyd,我已经部分解决了这个问题.我想,类路径配置中仍然存在一些问题.现在Maven找到了主类和jar,但是在执行之后我在编译代码中得到了另一个NPE.查看blazegraph的开源代码,似乎无法打开可执行jar内的资源.
以下是导致NPE的行:
System.setProperty("jetty.home",
jettyXml.getClass().getResource("/war").toExternalForm());
Run Code Online (Sandbox Code Playgroud)
classpath nullpointerexception maven-3 maven exec-maven-plugin
我正在尝试使用 webpack 分发基于节点的库。我已经看到大多数 js 库都可以用于:
commonJs 语法
const lib = require('library')
或 ES6 语法
import * as lib from "library"
我遵循了本教程,最终的 webpack.config.js 如下所示:
var path = require('path');
module.exports = {
entry: './index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'sepa.js',
library: 'sepajs',
libraryExport: 'default',
libraryTarget: 'umd',
umdNamedDefine: true,
globalObject: "typeof self !== 'undefined' ? self : this"
}
};
Run Code Online (Sandbox Code Playgroud)
虽然在浏览器上这个导入语句会导致一个空模块:
import * as SepaJs from "./sepa.js"
Run Code Online (Sandbox Code Playgroud)
webpack 是否假设将基于 commonJs 的库导出到 ES6 模块库?我应该用 babel 编译它吗?我可以拥有一个包含两个模块解决方案的捆绑文件吗?