我会在一个网络中滑动所有的细胞,但我不解决.我的代码是:
SpreadsheetService service = new SpreadsheetService("MyApp");
try{
URL SPREADSHEET_URL = new URL("https://spreadsheets.google.com/feeds/worksheets/1-8ATDLTqmzo4QCQijeJ_swZAcmsh/public/full");
SpreadsheetFeed feed = service.getFeed(SPREADSHEET_URL,SpreadsheetFeed.class);
List<SpreadsheetEntry> spreadsheets = feed.getEntries();
if (spreadsheets.size() == 0){
System.out.println("NO SPREADSHEET");
}
for(int i = 0; i<spreadsheets.size(); i++){
System.out.println(spreadsheets.get(i).getTitle().getPlainText());
}
List<WorksheetEntry> worksheets = spreadsheets.get(0).getWorksheets();
for (int j=0; j<worksheets.size(); j++){
System.out.println(worksheets.get(j).getTitle().getPlainText());
URL listFeedUrl = worksheets.get(j).getListFeedUrl();
ListFeed listFeed = service.getFeed(listFeedUrl,ListFeed.class);
}
Run Code Online (Sandbox Code Playgroud)
它在最后一行报告的错误:
ListFeed listFeed = service.getFeed(listFeedUrl,ListFeed.class);
Run Code Online (Sandbox Code Playgroud)
当我编译我的代码有这个错误:
Exception in thread "main" java.lang.ClassCastException: com.google.gdata.data.TextContent cannot be cast to com.google.gdata.data.OutOfLineContent
at com.google.gdata.data.spreadsheet.WorksheetEntry.getFeedUrlString(WorksheetEntry.java:129)
at com.google.gdata.data.spreadsheet.WorksheetEntry.getListFeedUrl(WorksheetEntry.java:98)
at it.unical.mat.google_data.MySpreadsheetIntegration.main(MySpreadsheetIntegration.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) …Run Code Online (Sandbox Code Playgroud) 我发现我的活动onStop()方法将在不到10秒的时间内被调用.我以前从未见过这种行为.
注意: -活动是
singleTop,它以Intent.FLAG_ACTIVITY_REORDER_TO_FRONTflag 开头.注意: -我正在使用Build Tools v23.0.2.
延迟不是之前,方法将立即调用.
我在使用jackson-core-2.7.3.jar解析JSON时遇到问题你可以从这里得到它们http://repo1.maven.org/maven2/com/fasterxml/jackson/core/
我的JSON文件是
[
{
"Name": "System Idle Process",
"CreationDate": "20160409121836.675345+330"
},
{
"Name": "System",
"CreationDate": "20160409121836.675345+330"
},
{
"Name": "smss.exe",
"CreationDate": "20160409121836.684966+330"
}
]
Run Code Online (Sandbox Code Playgroud)
而Java代码是我试图解析的
byte[] mapData = Files.readAllBytes(Paths.get("process.txt"));
Map<String,String> myMap = new HashMap<String, String>();
ObjectMapper objectMapper=new ObjectMapper();
myMap = objectMapper.readValue(mapData, HashMap.class);
System.out.println("Map is: "+myMap);
Run Code Online (Sandbox Code Playgroud)
但在执行时我收到了错误
com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.util.HashMap out of START_ARRAY token
at [Source: [B@34ce8af7; line: 1, column: 1]
at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:216)
at com.fasterxml.jackson.databind.DeserializationContext.mappingException(DeserializationContext.java:873)
at com.fasterxml.jackson.databind.DeserializationContext.mappingException(DeserializationContext.java:869)
at com.fasterxml.jackson.databind.deser.std.StdDeserializer._deserializeFromEmpty(StdDeserializer.java:874)
at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:337)
at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:26)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3789)
at …Run Code Online (Sandbox Code Playgroud) 我有一个如下所示的请求:
package pricing
import scala.beans.BeanProperty
class Request(@BeanProperty var name: String, @BeanProperty var surname: String) {
def this() = this(name="defName", surname="defSurname")
}
Run Code Online (Sandbox Code Playgroud)
处理程序如下:
package pricing
import com.amazonaws.services.lambda.runtime.{Context, RequestHandler}
import scala.collection.JavaConverters
import spray.json._
class ApiGatewayHandler extends RequestHandler[Request, ApiGatewayResponse] {
import DefaultJsonProtocol._
def handleRequest(input: Request, context: Context): ApiGatewayResponse = {
val headers = Map("x-foo" -> "coucou")
val msg = "Hello " + input.name
val message = Map[String, String]("message" -> msg )
ApiGatewayResponse(
200,
message.toJson.toString(),
JavaConverters.mapAsJavaMap[String, Object](headers),
true
)
}
}
Run Code Online (Sandbox Code Playgroud)
已被记录为:
functions:
pricing: …Run Code Online (Sandbox Code Playgroud) 我喜欢在我的 web 项目中添加 spring 安全性,当我添加安全性并扩展WebSecurityConfigurerAdapter时,当我启动 tomcat 服务器时出现以下错误:
java.lang.NoClassDefFoundError: org/springframework/security/web/access/WebInvocationPrivilegeEvaluator
at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_101]
at java.lang.Class.privateGetDeclaredMethods(Unknown Source) ~[na:1.8.0_101]
at java.lang.Class.getDeclaredMethods(Unknown Source) ~[na:1.8.0_101]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:613) ~[spring-core-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:524) ~[spring-core-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:510) ~[spring-core-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:570) ~[spring-core-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:697) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:640) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:609) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1484) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:425) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:395) ~[spring-beans-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:96) ~[spring-context-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:687) ~[spring-context-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:525) ~[spring-context-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.8.RELEASE.jar:1.5.8.RELEASE] …Run Code Online (Sandbox Code Playgroud) 我有一个很多麻烦的问题Spring Data,并MongoDB当它涉及到一个索引的字段.
我已经在文档,但他们不是在解释之间的差别非常好的@Indexed(unique=true)和@Indexed(unique=false).
我有一个我想索引的字段,所以我可以对它执行快速查询.在这种情况下,它的电子邮件地址通常应该是唯一的,但emailAddress可能在一段时间内为空.
但是,一旦将一条记录作为null emailAddress,我就不能拥有任何其他具有null emailAddress的记录.Spring Data拒绝使用null emailAddresses插入任何其他记录.它没有抛出任何不起作用的东西.
现在我把它设置为unique=true,但我正在考虑设置它来unique=false解决这个问题.
这会解决这个问题吗?
还有什么其他问题我可以通过放松这个来添加?
MongoDB是否允许我拥有多个相同且仍能快速查询的电子邮件地址?
我正在尝试使用Hibernate EntityManager persist方法将一个人pojo插入mysql数据库,
entityManagerTransactionService.getEntityManager().persist(TemplateObject);
Run Code Online (Sandbox Code Playgroud)
得到这个例外,
javax.persistence.PersistenceException:
org.hibernate.PersistentObjectException: detached entity passed to
persist: com.esupu.base.model.pojo.common.TitleType at
org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1387)....
Run Code Online (Sandbox Code Playgroud)
还有更多......
Caused by: org.hibernate.PersistentObjectException: detached entity
passed to persist: com.esupu.base.model.pojo.common.TitleType at
org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:141)
at
org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:843)
Run Code Online (Sandbox Code Playgroud)
我的Person.java类是,
@Entity
public class Person extends TemplateObject {
@OneToOne(cascade = { CascadeType.MERGE, CascadeType.PERSIST,CascadeType.REFRESH })
private TitleType titleType;
private String middle;
private String last;
@OneToOne(cascade = { CascadeType.ALL })
private Address address;
private Date birthdate;
private String email;
private String telephone;
private String fax;
@OneToOne(cascade = { CascadeType.ALL })
private Location location; …Run Code Online (Sandbox Code Playgroud) 我将jpg图像存储在数据库中(作为字节数组).我想避免在显示在网页上之前删除文件系统.
单元测试表明数据库存储和检索工作没有损坏.可以从数据库中提取Fies并将其转换回jpg文件
图像已转换为bytearray并使用以下代码存储在数据库中:
public static byte[] getImageAsBytes(BufferedImage buffer) throws IOException
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(buffer, "jpg", baos);
baos.flush();
byte[] imageInByte = baos.toByteArray();
baos.close();
return imageInByte;
}
Run Code Online (Sandbox Code Playgroud)
我有一个ViewWrapperMediaImage类,它包含从数据库中检索的字节数组.该类还有一个将bytearray转换为base64 String的方法.
package jake.prototype2.controller.viewwrapper;
import org.apache.commons.codec.binary.Base64;
import jake.prototype2.model.assessment.MediaImage;
import jake.prototype2.model.assessment.TestStructureException;
import jake.prototype2.model.structure.InterfacePersistenceBean;
public class ViewWrapperMediaImageCreate extends ViewWrapperTestContentElementCreate
{
private byte[] image;
protected String mediaFileName;
private static final long serialVersionUID = 4181515305837289526L;
public ViewWrapperMediaImageCreate(InterfacePersistenceBean persistenceBean) throws TestStructureException
{
....
}
}
public byte[] getImage()
{
return image;
}
public String generateBase64Image()
{
return …Run Code Online (Sandbox Code Playgroud) 在我的application.yml中,我得到了:
logging:
config: classpath:log4j2.debug.yml
Run Code Online (Sandbox Code Playgroud)
以及其他一些不同的配置文件.当我启动应用程序时,我得到以下内容:
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
Run Code Online (Sandbox Code Playgroud)
如果我只是将log4j2.xml放在配置文件的旁边,那就可以了.所以我认为这是一个我错过了依赖性的东西,或者用log4j2是不可能的?
参考:引导记录级别说我应该可以试试吗?
我有一个xml字符串,我想用JSON字符串转换
var txt = "<?xml version='1.0' encoding='UTF-8' ?>
<result>
<info>
<id>1</id>
<type>HL</type>
<ven>DEMOMA</ven>
</info>
<info>
<id>2</id>
<type>HL</type>
<ven>DEMOMB</ven>
</info>
<result>";
Run Code Online (Sandbox Code Playgroud)
我试图最初使用解析器在DOM对象中转换它,但它会抛出解析错误.
parser = new DOMParser();
xmlDoc = parser.parseFromString(txt,"text/xml");
Run Code Online (Sandbox Code Playgroud)
我希望我的输出json字符串只能使用Javascript
{"result":[{"id":"1","type":"HL","ven":"DEMOMA"},{"id":"2","type":"HL","ven":"DEMOMB"}]}
Run Code Online (Sandbox Code Playgroud) java ×5
android ×2
json ×2
spring-boot ×2
annotations ×1
aws-lambda ×1
feed ×1
hibernate ×1
jackson ×1
javascript ×1
jpa ×1
lag ×1
log4j2 ×1
mongodb ×1
scala ×1
spreadsheet ×1
spring ×1
spring-data ×1
thymeleaf ×1
worksheet ×1