小编ami*_*que的帖子

Spring批处理管理员:无法读取663 MB平面文件,OutOfMemoryError

我在Tomcat 7中使用Spring Batch Admin 1.2.1.我正在尝试读取663 MB文件并收到以下错误.我也增加了Tomcat的堆大小但没有白费.这项工作非常直接.它读取平面文件并将其保存到DB,只需很少的处理.请帮忙.

15:05:10,535  INFO http-apr-8181-exec-4 SimpleStepHandler:133 - Executing step: [load]
    15:05:10,981 ERROR http-apr-8181-exec-4 AbstractStep:212 - Encountered an error executing the step
java.lang.OutOfMemoryError: Java heap space
    at org.apache.catalina.loader.WebappClassLoader.findResourceInternal(WebappClassLoader.java:3098)
    at org.apache.catalina.loader.WebappClassLoader.findResource(WebappClassLoader.java:1244)
    at org.apache.catalina.loader.WebappClassLoader.getResource(WebappClassLoader.java:1407)
    at org.springframework.core.io.ClassPathResource.exists(ClassPathResource.java:139)
    at org.springframework.batch.item.file.FlatFileItemReader.doOpen(FlatFileItemReader.java:248)
    at org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader.open(AbstractItemCountingItemStreamItemReader.java:134)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
    at $Proxy30.open(Unknown Source)
    at org.springframework.batch.item.support.CompositeItemStream.open(CompositeItemStream.java:93)
    at org.springframework.batch.core.step.item.ChunkMonitor.open(ChunkMonitor.java:105)
    at org.springframework.batch.item.support.CompositeItemStream.open(CompositeItemStream.java:93)
    at org.springframework.batch.core.step.tasklet.TaskletStep.open(TaskletStep.java:301)
    at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:192)
    at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:135) …
Run Code Online (Sandbox Code Playgroud)

spring spring-batch tomcat7 spring-batch-admin

2
推荐指数
1
解决办法
1880
查看次数

Spring MVC REST Json Conversion异常

我正在关注一个简​​单的Spring MVC REST示例.在PUT请求中,我遇到以下异常:

org.springframework.http.converter.HttpMessageNotReadableException: Could not read JSON: Unrecognized field "property" (Class domain.Property), not marked as ignorable
    at [Source: org.apache.catalina.connector.CoyoteInputStream@75280b93; line: 1, column: 14] (through reference chain: domain.Property["property"]); 
nested exception is org.codehaus.jackson.map.exc.UnrecognizedPropertyException:                               
    Unrecognized field "property" (Class domain.Property), not marked as ignorable
    at [Source: org.apache.catalina.connector.CoyoteInputStream@75280b93; line: 1, column: 14] (through reference chain: domain.Property["property"])
Run Code Online (Sandbox Code Playgroud)

我收到了以下JSON

{"property":
    {
        "name":"name",
        "age":"22"
    }
}
Run Code Online (Sandbox Code Playgroud)

以下是我的REST方法:

@RequestMapping(method = RequestMethod.PUT, value = "/{id}")
public ResponseEntity<Property> updateProperty(@RequestBody Property property,
                                               @PathVariable String id) {   
  final ResponseEntity<Property> response = 
          new …
Run Code Online (Sandbox Code Playgroud)

java rest spring json spring-mvc

2
推荐指数
1
解决办法
4087
查看次数

OWASP HTML Sanitizer允许在HTML中使用冒号

如何:签署已清理的HTML?我用它来生成java邮件时清理HTML代码.此代码具有内联图像内容ID <img src=\"cid:image\" height=\"70\" width=\"70\" />.在src清理时,该属性不包含在已清理的html中.

    PolicyFactory IMAGES = new HtmlPolicyBuilder().allowUrlProtocols("http", "https")
            .allowElements("img")
            .allowAttributes("src").matching(Pattern.compile("^cid[:][\\w]+$"))
            .onElements("img")
            .allowAttributes("border", "height", "width").onElements("img")
            .toFactory();

    String html = "<img src=\"cid:image\"  height=\"70\" width=\"70\" />";
    final String sanitized = IMAGES.sanitize(html);

    System.out.println(sanitized);
Run Code Online (Sandbox Code Playgroud)

上面代码的输出是:

<img height="70" width="70" />
Run Code Online (Sandbox Code Playgroud)

xss jakarta-mail html-sanitizing owasp

2
推荐指数
1
解决办法
1277
查看次数

MySQL的LOAD DATA INFILE不起作用

我正在尝试在命令行上使用mysql LOAD DATA INFILE加载csv文件。它既不会给出任何错误,也不会加载任何数据。有人可以帮我吗?我正在使用以下命令

mysql> LOAD DATA INFILE '/Applications/XAMPP/xamppfiles/htdocs/dev/__php__/mysql/data.csv'
->             INTO TABLE csvdata
->               FIELDS TERMINATED BY ','
->               OPTIONALLY ENCLOSED BY '"'
->               LINES TERMINATED BY '\n'
->               IGNORE 1 LINES;
Query OK, 0 rows affected (0.00 sec)
Records: 0  Deleted: 0  Skipped: 0  Warnings: 0
Run Code Online (Sandbox Code Playgroud)

以下是我的CSV文件

"emp_id","first_name","last_name","username"
"EMP1","Tibass","Deloris","Tibass1"
Run Code Online (Sandbox Code Playgroud)

问候

mysql csv

1
推荐指数
1
解决办法
7417
查看次数

字符串空白(空或空)检查:如果结构 vs java 8 可选/过滤器

问题:哪种方法更好,为什么

1- 使用 Apache Commons

if(StringUtils.isNotBlank(str) {
     list.add(str)
}
Run Code Online (Sandbox Code Playgroud)

2- 可选和过滤器

Optional.ofNullable(str)
                .filter(s -> StringUtils.isNotBlank(s))
                .ifPresent(result -> list.add(result));
Run Code Online (Sandbox Code Playgroud)

java java-8

0
推荐指数
1
解决办法
1487
查看次数