Clojure maven插件启动nrepl

时间:2018-05-25 10:46:02

标签: maven clojure 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)

1 个答案:

答案 0 :(得分:1)

根据the docs

  

clojure:nrepl目标需要org.clojure / tools.nrepl作为项目依赖

尝试将插件中的依赖项移动到您已声明对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>