Clojure maven 插件启动 nrepl

Clojure maven plugin start nrepl

我正在尝试配置一个使用 clojure 的 Maven 项目,我想在其中启动 nrepl
我用这个配置做了一个最小的 maven 项目:

<!-- some standard pom stuff -->
<dependencies>
    <dependency>
        <groupId>org.clojure</groupId>
        <artifactId>clojure</artifactId>
        <version>1.9.0</version>
    </dependency>
</dependencies>

<build>
<plugins>
    <plugin>
      <groupId>com.theoryinpractise</groupId>
      <artifactId>clojure-maven-plugin</artifactId>
      <version>1.8.1</version>
      <extensions>true</extensions>
      <dependencies>
          <dependency>
              <groupId>org.clojure</groupId>
              <artifactId>tools.nrepl</artifactId>
              <version>0.2.13</version>
          </dependency>
      </dependencies>
    </plugin>
</plugins>
<!-- other maven standard stuffs -->

当我这样做时 mvn clojure:nrepl 我遇到了这个错误:

[INFO] --- clojure-maven-plugin:1.8.1:nrepl (default-cli) @ clojure-maven-integration ---
Exception in thread "main" java.io.FileNotFoundException: Could not locate clojure/tools/nrepl/server__init.class or clojure/tools/nrepl/server.clj on classpath.
    at clojure.lang.RT.load(RT.java:463)
    at clojure.lang.RT.load(RT.java:426)
    at clojure.core$load$fn__6548.invoke(core.clj:6046)
    at clojure.core$load.invokeStatic(core.clj:6045)
    at clojure.core$load.doInvoke(core.clj:6029)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojure.core$load_one.invokeStatic(core.clj:5848)
    at clojure.core$load_one.invoke(core.clj:5843)
    at clojure.core$load_lib$fn__6493.invoke(core.clj:5888)
    at clojure.core$load_lib.invokeStatic(core.clj:5887)
    at clojure.core$load_lib.doInvoke(core.clj:5868)
    at clojure.lang.RestFn.applyTo(RestFn.java:142)
    at clojure.core$apply.invokeStatic(core.clj:659)
    at clojure.core$load_libs.invokeStatic(core.clj:5925)
    at clojure.core$load_libs.doInvoke(core.clj:5909)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invokeStatic(core.clj:659)
    at clojure.core$require.invokeStatic(core.clj:5947)
    at clojure.core$require.doInvoke(core.clj:5947)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at user$eval11.invokeStatic(NO_SOURCE_FILE:1)
    at user$eval11.invoke(NO_SOURCE_FILE:1)
    at clojure.lang.Compiler.eval(Compiler.java:7062)
    at clojure.lang.Compiler.eval(Compiler.java:7025)
    at clojure.core$eval.invokeStatic(core.clj:3206)
    at clojure.main$eval_opt.invokeStatic(main.clj:291)
    at clojure.main$eval_opt.invoke(main.clj:285)
    at clojure.main$initialize.invokeStatic(main.clj:311)
    at clojure.main$null_opt.invokeStatic(main.clj:345)
    at clojure.main$null_opt.invoke(main.clj:342)
    at clojure.main$main.invokeStatic(main.clj:424)
    at clojure.main$main.doInvoke(main.clj:387)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.lang.Var.applyTo(Var.java:702)
    at clojure.main.main(main.java:37)

根据the docs

The clojure:nrepl goal requires org.clojure/tools.nrepl as a project dependency

尝试将嵌套在插件中的依赖项移动到您声明对 Clojure 的依赖项的位置。

POM 示例:

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>foo</groupId>
  <artifactId>bar</artifactId>
  <version>1.0-SNAPSHOT</version>

  <name>bar</name>
  <description>A simple bar.</description>

  <dependencies>
    <dependency>
      <groupId>org.clojure</groupId>
      <artifactId>clojure</artifactId>
      <version>1.9.0</version>
    </dependency>
    <dependency>
      <groupId>org.clojure</groupId>
      <artifactId>tools.nrepl</artifactId>
      <version>0.2.13</version>
    </dependency>
  </dependencies>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>com.theoryinpractise</groupId>
          <artifactId>clojure-maven-plugin</artifactId>
          <version>1.8.1</version>
          <extensions>true</extensions>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
</project>