在eclipse中设置maven java项目[关闭](Setup maven java project in eclipse [closed])
如何让Eclipse管理由maven构建的项目的类? 我目前正在使用eclipse的
Spring Tool Suite
发行版,而我正在研究的项目使用maven项目根pom
和一些我不想修改的pom
子模块。How can I make Eclipse manage the classes of a project built by maven? I'm currently using the
Spring Tool Suite
distribution of eclipse, and the project I'm working on uses a maven project rootpom
and a number ofpom
submodules which I wouldn't like to modify.
原文:https://stackoverflow.com/questions/27061716
最满意答案
你确定你在两个项目中使用相同的jar吗?
Android的
org.json.JSONObject.toString(String)
是不同的:/** * Returns the value mapped by {@code name} if it exists, coercing it if * necessary, or throws if no such mapping exists. * * @throws JSONException if no such mapping exists. */ public String getString(String name) throws JSONException { Object object = get(name); String result = JSON.toString(object); if (result == null) { throw JSON.typeMismatch(name, object, "String"); } return result; }
JSON.toString(Object)
:static String toString(Object value) { if (value instanceof String) { return (String) value; } else if (value != null) { return String.valueOf(value); } return null; }
在你的情况下,这不会在Android上引发异常。
Are you sure you are using the same jar in both projects?
Android's
org.json.JSONObject.toString(String)
is different:/** * Returns the value mapped by {@code name} if it exists, coercing it if * necessary, or throws if no such mapping exists. * * @throws JSONException if no such mapping exists. */ public String getString(String name) throws JSONException { Object object = get(name); String result = JSON.toString(object); if (result == null) { throw JSON.typeMismatch(name, object, "String"); } return result; }
JSON.toString(Object)
:static String toString(Object value) { if (value instanceof String) { return (String) value; } else if (value != null) { return String.valueOf(value); } return null; }
In your case this would not throw an exception on Android.
相关问答
更多-
如何解释这个看起来不一致的Java可变参数行为?(How can one explain this seemingly inconsistent Java varargs behavior?)[2022-06-15]
Arrays.asList被定义为具有参数T... ,并且主体将它看作T[]类型的一个参数。 但是, T 必须是引用类型 (如任何类型参数),并且int不是引用类型。 因此,没有办法使new int[]{...}与可变参数的数组兼容。 (结果将是List,这是不允许的。)唯一的选择是将它作为单个对象处理,因此这里的T将是int[] ,它是一个引用类型,函数将返回List 。 我认为这是原因,但我仍然需要查找确切的语言。 它可能涉及我没有掌握的类型推理规则。 但是,我确实尝试了这一点 ... -
原因在于三元经营者的工作方式。 它总是将两个对象都转换为与这两个对象通用的最接近的超类型。 在你的情况下,它是BaseInterpolator ,因为你的targetSDK版本设置为23 。 但是,由于您的minSDK为14 ,因此演员阵容无法在所有设备上运行。 因此错误。 为了解决这个问题,你可以为这两个对象添加一个TimeInterpolator的显式类型。 The reason is because of the way ternary operators work. It always casts ...
-
新的java / android - 了解线程不一致的状态(new to java/android - understanding thread inconsistent state)[2023-07-14]
试图避免的情况被称为竞争条件 : http://en.wikipedia.org/wiki/Race_condition 序列的结果 int myColorInt = color.getRGB(); //Statement 1 String myColorName = color.getName(); //Statement 2 取决于在其他线程中执行的此代码线程的时序 。 如果另一个线程在这两个语句之间设置颜色,则存储在myColorName的名称将与myColorName存储的颜色不匹配。 ... -
你确定你在两个项目中使用相同的jar吗? Android的org.json.JSONObject.toString(String)是不同的: /** * Returns the value mapped by {@code name} if it exists, coercing it if * necessary, or throws if no such mapping exists. * * @throws JSONException if no such mapping exists. * ...
-
您的问题的答案是: 不 ,这不是Java或Android中的错误。 记录良好的行为。 Calendar实例的字段数多于YEAR,MONTH和DATE。 您生成新的日历实例并仅更改这些字段,将所有其他字段保留为创建方式。 如果连续两次运行程序,则秒和毫秒将同时更改。 来自JavaDoc : 设置日历字段YEAR,MONTH和DAY_OF_MONTH的值。 保留其他日历字段的先前值。 如果不需要,请先调用clear() 。 为了每次都打印相同的值,您需要这样做: Calendar calendar1 = ...
-
如果你看一下第一个循环中arr会发生什么,那就很明显了。 int[] arr = {1, 2, 3, 4}; for (int i : arr) { System.out.println("i = " + i); arr[i] = 0; System.out.println("arr = " + Arrays.toString(arr)); } for (int i : arr) { System.out.pr ...
-
BufferedImage.getRGB()方法始终在非线性 sRGB颜色空间( ColorSpace.CS_sRGB )中返回颜色(作为“压缩格式”中的int )。 无论您的图像具有什么颜色空间和每像素位等,它都会这样做。 因此,可能发生转换和可能的精度损失。 来自JavaDoc : 返回默认RGB颜色模型(TYPE_INT_ARGB)和默认sRGB颜色空间中的整数像素。 如果此默认模型与图像ColorModel不匹配,则会进行颜色转换。 您的TYPE_BYTE_GRAY图像在内部使用线性灰色空间( Co ...
-
assoc行为是否不一致?(Is assoc behavior inconsistent?)[2023-04-30]
Assoc-in使用assoc来修改所提供密钥的元素(在您的情况下为索引)。 Assoc-in(和assoc)尝试创建所需的键(或索引)。 关联向量的特殊处理在assoc docstring中提到: 应用于向量时,返回包含val的索引的新向量。 注 - 索引必须是<=(计数向量) 。 更新:只是为了澄清:缺少的异常是一致的,因为0是空向量中新元素的有效索引,1不是。 Assoc-in uses assoc to modify the element at the supplied key (index in ... -
局部变量out_h,out_s,out_v未初始化,因此行为未定义。 ushort out_h, out_s, out_v; 如果你将它们初始化为0,我认为问题应该消失了。 Local variable out_h, out_s, out_v are not initialized, so the behavior is undefined. ushort out_h, out_s, out_v; If you initialize them to be 0, I think the problem s ...
-
该错误表明在您的设备(或模拟器)上运行的代码,在onCreate()方法的EditorActivity.java的第31行,您正在尝试强制转换为ImageView,但您拥有的是GLSurfaceView。 Caused by: java.lang.ClassCastException: android.opengl.GLSurfaceView cannot be cast to android.widget.ImageView at com.example.ekalips.EditorActivity.on ...