草庐IT

reference-type

全部标签

java - 为什么我会收到错误 "File cannot be resolved to a type"?

这是我的部分代码try{BufferedReaderin=newBufferedReader(newInputStreamReader(System.in));while((line=in.readLine())!="exit"){System.out.println("Entercommand");line=in.readLine();CommandcurrentCommand=newCommand(line);FilecurrentFile=newFile(currentCommand.getLsPath());currentCommand.getLsPath()方法返回一个字符串

java - 我如何反对像 Java 这样的强类型语言中的 Duck-typing?

我在一个Java程序员团队工作。我的一位同事不时建议我做一些类似“只添加一个类型字段”(通常是“字符串类型”)的事情。否则代码将被提交满载“if(fooinstanceofFoo){...}elseif(fooinstanceofBar){...}”。尽管乔什·布洛赫(JoshBloch)告诫说“标记类是对适当类层次结构的wan模仿”,但我对这种事情的唯一react是什么?然后我如何更认真地阐述这个概念?我很清楚-上下文是Java-正在考虑的对象类型就在我们集体面前-IOW:紧跟在“类”、“枚举”或“接口(interface)”等之后的词。但是除了难以证明或量化(当场)“它使您的代码更

java - Play Framework : PersistenceException: The type is not a registered entity? (Ebean)

我正在学习适用于Java的PlayFramework2.0教程,但在尝试保存ebean模型(task.save())时遇到此错误。[PersistenceException:Thetype[classmodels.Task]isnotaregisteredentity?Ifyoudon'texplicitlylisttheentityclassestouseEbeanwillsearchforthemintheclasspath.IftheentityisinaJarchecktheebean.search.jarspropertyinebean.propertiesfileorche

java - 得到一个 The entity name must immediately follow the '&' in the entity reference error in java, 但我的 xml 文件中没有任何符号

我遇到了错误Theentitynamemustimmediatelyfollowthe'&'intheentityreference.但我的XML文档中没有任何符号!有谁知道为什么会发生这种情况?这是我要解析的XML文档:BestiPadstrategygameshttp://feedproxy.google.com/~r/TheIphoneBlog/~3/198mhX3FVmw/story01.htmShareyourlifewithfriendsinrealtimewithSpinhttp://feedproxy.google.com/~r/TheIphoneBlog/~3/9G8

java - 注释 "not applicable to type"

多年来我一直是IntelliJ的Eclipse用户,所以我真的发现了这个错误,所有对@Override的注释都显示错误“notapplicabletotype”例如,来自JBossErrai的@PostConstruct注释到处都显示此错误,其中导入完全没有错误。我该如何解决这个问题?更新:例如@PostConstruct//Whenhoveredwiththemousepointer'@PostContruct'isnotapplicabletomethodpublicvoidinit(){}截图:http://snag.gy/q5cW5.jpg 最佳答案

java - 使用 Java ODBC 创建连接会导致 java.sql.SQLException : Invalid Cursor Type exception

我正在尝试创建一个访问ODBC数据源的Java程序。使用以下代码...Connectionconn;try{Driverd=(Driver)Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();DriverManager.registerDriver(d);StringURL="jdbc:odbc:ARSystemODBCDataSource";conn=DriverManager.getConnection(URL);}catch(SQLException|InstantiationException|IllegalA

java - 混合模式下的 jstack : WrongTypeException: No suitable match for type of address

我正在尝试以混合模式在ubuntu上运行jstack:$jstack-m7219结果是这个异常:AttachingtoprocessID7219,pleasewait...Debuggerattachedsuccessfully.Servercompilerdetected.JVMversionis25.162-b12Exceptioninthread"main"java.lang.reflect.InvocationTargetExceptionatsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.refl

java - 有没有关于 Gson "circular reference"的解决方案?

我找了很多关于Gson循环引用的文章,但是我找不到一个优雅的解决方案。据我所知,一些解决方案是:将导致循环引用的属性设置为“transient”。用一些注释排除属性。但作为一个一般性问题,是否有一些通用的策略来解决这个问题? 最佳答案 据我所知,在Gson中没有针对循环引用的自动化解决方案。我所知道的唯一一个自动处理循环引用的生成JSON的库是XStream(使用Jettison后端)。编辑:Jackson还支持使用@JsonIdentityInfo注释处理循环引用;因此虽然不是自动的(您确实需要标记需要处理对象ID的引用),但它确

Java 泛型 : how to get a generic type from a method?

虽然我的问题是关于Java泛型的,但我已经放了一些与JPA相关的代码来向您展示真实的上下文。我正在使用JPA2.0和基于CriteriaAPI的查询。我所有的查询都遵循相同的模式(比较简单的属性;不需要路径导航),所以我试图编写一个通用类来处理JPA,同时将业务逻辑保留在单独的类中。我的目标是有一个方法,给定一个实体类型和一个存储定义标准的对(字段名称->期望值)的映射,返回一个具有某些实体字段值的bean(或bean集合).我所有的实体都实现了Persistible接口(interface),而我所有的传输对象都继承自QueryBean.我认为那些类与问题无关,因此我跳过了它们的代码

java - Spring PUT 请求 : Unsupported Media Type (Code: 415)

我有一个相当晦涩的问题,经过几天的调试后我无法弄清楚。问题是我们的PUTRESTAPI之一开始在生产中抛出UnsupportedMediatype。下面是方法的定义:@RequestMapping(value="/v1/put/user/profile",method=RequestMethod.PUT)publicStringupdateProfile(@RequestBodyUserAndroiduser,ModelMapmodel,HttpServletRequestrequest,HttpServletResponseresponse){}在PUT请求中,我们只是传递手机号码,