无法在本地设置Marklogic Java Api?

时间:2018-01-20 04:10:01

标签: java marklogic

我已经安装了ML 9.0.3,并按照此document进行了本地设置,并根据我的要求修改了config.properties

# properties to configure the examples
example.admin_password=x
example.host=localhost
example.port=9963
example.authentication_type=digest

当我在控制台中运行第一个程序时,它会抛出这样的错误:

example: com.marklogic.client.example.tutorial.Example_01_CreateJSON
Exception in thread "main" java.lang.IllegalArgumentException: No user provided
    at com.marklogic.client.impl.JerseyServices.connect(JerseyServices.java:186)
    at com.marklogic.client.impl.JerseyServices.connect(JerseyServices.java:165)
    at com.marklogic.client.DatabaseClientFactory.newClient(DatabaseClientFactory.java:156)
    at com.marklogic.client.DatabaseClientFactory.newClient(DatabaseClientFactory.java:125)
    at com.marklogic.client.example.tutorial.Example_01_CreateJSON.main(Example_01_CreateJSON.java:37)

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:2)

错误消息似乎表明在第37行尝试连接时没有指定用户名:

DatabaseClient client = DatabaseClientFactory.newClient(Config.host, Config.port, Config.user, Config.password, Config.authType);

我在您提供的媒体资源中看不到用户名属性。本教程显示了config.properties(您提供的属性中缺少这些属性):

example.admin_user=rest-admin
example.writer_user=rest-writer
example.writer_password=x

Example_01_CreateJSON的代码引用Config.user,它来自example.writer_user属性:

protected static String user = props.getProperty("example.writer_user");

您的属性文件必须定义example.writer_user值才能知道登录的对象。