2017-09-08 122 views
1

我的代码创建:ClassNotFoundException的使用创一流

(ns model.document 
    (:gen-class 
    :name model.document 
    :implements java.io.Serializable 
    :state "state" 
    :init "init" 
    :constructors {[String String String] []} 
    :methods [[getContent [] String] 
       [getTitle [] String] 
       [getUrl [] String]])) 

(defn -init [content title url] 
    [[] (atom {:content content 
      :title title 
      :url url})]) 

(defn- get-field [this k] 
    (@(.state this) k)) 

(defn getContent [this] 
    (get-field this :content)) 

(defn getTitle [this] 
    (get-field this :title)) 

(defn getUrl [this] 
    (get-field this :url)) 

而且它的使用:

(ns classification-server.classifier 
    (:require [model.document :refer :all])) 

(new model.document "my-content" "my-title" "my-url") 

我也得到了无益:

Caused by: java.lang.ClassNotFoundException: model.document, compiling:(classification_server/classifier.clj:13:12) 

请帮助我是。你是我唯一的希望...

回答

5

你发布的gen-class命名空间不能编译,因为:implements规范需要一个符号向量,而不是符号向量。如果把上面一行

:implements [java.io.Serializable] 

,你将能够编译(和实例)类 - 但是,它不会是功能性的,因为还有其他一些问题与创一流的规范,如前缀功能不存在(-getContent等)。

我建议您阅读gen-class documentation并进一步简化 问题。

相关问题