gpt4 book ai didi

java - 构建json相关问题

转载 作者:行者123 更新时间:2023-12-02 04:28:24 25 4
gpt4 key购买 nike

当我尝试运行 antbuild 时,我在控制台中收到这些错误。请帮助我解决这些错误。我还在 Web\lib 中包含了所有需要的 jars..

Buildfile: J:\workspace\new\bluemixx\WordGuess\build.xml
clean:
[delete] Deleting directory J:\workspace\new\bluemixx\WordGuess\bin
init:
[mkdir] Created dir: J:\workspace\new\bluemixx\WordGuess\bin
build-project:
[echo] WebStarterApp: J:\workspace\new\bluemixx\WordGuess\build.xml
[javac] Compiling 7 source files to J:\workspace\new\bluemixx\WordGuess\bin
[javac] J:\workspace\new\bluemixx\WordGuess\src\com\bluemix\hangman\data\CloudantConnection.java:7: error: package org.apache.wink.json4j does not exist
[javac] import org.apache.wink.json4j.JSONArray;
[javac] ^
[javac] J:\workspace\new\bluemixx\WordGuess\src\com\bluemix\hangman\data\CloudantConnection.java:8: error: package org.apache.wink.json4j does not exist
[javac] import org.apache.wink.json4j.JSONObject;
[javac] ^
[javac] J:\workspace\new\bluemixx\WordGuess\src\com\bluemix\hangman\model\Category.java:18: error: package com.fasterxml.jackson.annotation does not exist
[javac] import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
[javac] ^
[javac] J:\workspace\new\bluemixx\WordGuess\src\com\bluemix\hangman\model\Category.java:19: error: package com.fasterxml.jackson.annotation does not exist
[javac] import com.fasterxml.jackson.annotation.JsonProperty;
[javac] ^
[javac] J:\workspace\new\bluemixx\WordGuess\src\com\bluemix\hangman\model\Category.java:21: error: cannot find symbol
[javac] @JsonIgnoreProperties({"id", "revision"})
[javac] ^
[javac] symbol: class JsonIgnoreProperties
[javac] J:\workspace\new\bluemixx\WordGuess\src\com\bluemix\hangman\model\Word.java:18: error: package com.fasterxml.jackson.annotation does not exist
[javac] import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
[javac] ^
[javac] J:\workspace\new\bluemixx\WordGuess\src\com\bluemix\hangman\model\Word.java:19: error: package com.fasterxml.jackson.annotation does not exist
[javac] import com.fasterxml.jackson.annotation.JsonProperty;
[javac] ^
[javac] J:\workspace\new\bluemixx\WordGuess\src\com\bluemix\hangman\model\Word.java:21: error: cannot find symbol
[javac] @JsonIgnoreProperties({"id", "revision"})
[javac] ^
[javac] symbol: class JsonIgnoreProperties
[javac] J:\workspace\new\bluemixx\WordGuess\src\com\bluemix\hangman\model\Category.java:24: error: cannot find symbol
[javac] @JsonProperty("_id")
[javac] ^
[javac] symbol: class JsonProperty
[javac] location: class Category
[javac] J:\workspace\new\bluemixx\WordGuess\src\com\bluemix\hangman\model\Category.java:27: error: cannot find symbol
[javac] @JsonProperty("_rev")
[javac] ^
[javac] symbol: class JsonProperty
[javac] location: class Category
[javac] J:\workspace\new\bluemixx\WordGuess\src\com\bluemix\hangman\model\Word.java:24: error: cannot find symbol
[javac] @JsonProperty("_id")
[javac] ^
[javac] symbol: class JsonProperty
[javac] location: class Word
[javac] J:\workspace\new\bluemixx\WordGuess\src\com\bluemix\hangman\model\Word.java:27: error: cannot find symbol
[javac] @JsonProperty("_rev")
[javac] ^
[javac] symbol: class JsonProperty
[javac] location: class Word
[javac] J:\workspace\new\bluemixx\WordGuess\src\com\bluemix\hangman\data\CloudantConnection.java:27: error: cannot find symbol
[javac] JSONObject obj = new JSONObject(System.getenv("VCAP_SERVICES"));
[javac] ^
[javac] symbol: class JSONObject
[javac] location: class CloudantConnection
[javac] J:\workspace\new\bluemixx\WordGuess\src\com\bluemix\hangman\data\CloudantConnection.java:27: error: cannot find symbol
[javac] JSONObject obj = new JSONObject(System.getenv("VCAP_SERVICES"));
[javac] ^
[javac] symbol: class JSONObject
[javac] location: class CloudantConnection
[javac] J:\workspace\new\bluemixx\WordGuess\src\com\bluemix\hangman\data\CloudantConnection.java:28: error: cannot find symbol
[javac] String[] names = JSONObject.getNames(obj);
[javac] ^
[javac] symbol: variable JSONObject
[javac] location: class CloudantConnection
[javac] J:\workspace\new\bluemixx\WordGuess\src\com\bluemix\hangman\data\CloudantConnection.java:33: error: cannot find symbol
[javac] JSONArray val = obj.getJSONArray(name);
[javac] ^
[javac] symbol: class JSONArray
[javac] location: class CloudantConnection
[javac] J:\workspace\new\bluemixx\WordGuess\src\com\bluemix\hangman\data\CloudantConnection.java:34: error: cannot find symbol
[javac] JSONObject serviceAttr = val.getJSONObject(0);
[javac] ^
[javac] symbol: class JSONObject
[javac] location: class CloudantConnection
[javac] J:\workspace\new\bluemixx\WordGuess\src\com\bluemix\hangman\data\CloudantConnection.java:35: error: cannot find symbol
[javac] JSONObject credentials = serviceAttr.getJSONObject("credentials");
[javac] ^
[javac] symbol: class JSONObject
[javac] location: class CloudantConnection
[javac] 18 errors

BUILD FAILED
J:\workspace\new\bluemixx\WordGuess\build.xml:30: Compile failed; see the compiler error output for details.

Total time: 539 milliseconds

当我尝试运行 antbuild 时,我在控制台中收到这些错误。请帮助我解决这些错误。我还在 Web\lib 中包含了所有需要的 jars..

最佳答案

请确保通过 ant 正确编译类,并在准备 jar/war 时...确保将 basedir 指定为包含所有类的目录,与 ant 编译源 java 的目录相同代码到类。

下面是一个简单的例子

`

<target name="clean">
<delete dir="build"/>
</target>

<target name="compile">
<mkdir dir="build/classes"/>
<javac srcdir="src" destdir="build/classes"/>
</target>

<target name="jar">
<mkdir dir="build/jar"/>
<jar destfile="build/jar/HelloWorld.jar" basedir="build/classes">
<manifest>
<attribute name="Main-Class" value="oata.HelloWorld"/>
</manifest>
</jar>
</target>

<target name="run">
<java jar="build/jar/HelloWorld.jar" fork="true"/>
</target>

`在这里你可以看到compile目标将java代码编译到build/classes中,jar目标从build/classes目录中的类创建jar

关于java - 构建json相关问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31842263/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com