我的代码:
(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))
Run Code Online (Sandbox Code Playgroud)
它的用途是:
(ns classification-server.classifier
(:require [model.document :refer :all]))
(new model.document "my-content" "my-title" "my-url")
Run Code Online (Sandbox Code Playgroud)
我得到了无益的帮助:
Caused by: java.lang.ClassNotFoundException: model.document, compiling:(classification_server/classifier.clj:13:12)
Run Code Online (Sandbox Code Playgroud)
请帮帮我.你是我唯一的希望...
您发布的gen-class命名空间无法编译,因为:implements规范需要符号向量而不是符号.如果您将该行更改为
:implements [java.io.Serializable]
Run Code Online (Sandbox Code Playgroud)
您将能够编译(并实例化)该类 - 但是,它将无法正常运行,因为您的gen-class规范还存在其他问题,例如缺少前缀函数(-getContent等等).
我建议你阅读gen-class文档并进一步简化问题.