小编xed*_*edo的帖子

Spring批处理作业从多个来源读取

如何从多个数据库中读取项目?我已经知道可以从文件中获取.
以下示例适用于从多个文件中读取

...
<job id="readMultiFileJob" xmlns="http://www.springframework.org/schema/batch">
    <step id="step1">
    <tasklet>
        <chunk reader="multiResourceReader" writer="flatFileItemWriter"
            commit-interval="1" />
    </tasklet>
    </step>
</job>
...
<bean id="multiResourceReader"
    class=" org.springframework.batch.item.file.MultiResourceItemReader">
    <property name="resources" value="file:csv/inputs/domain-*.csv" />
    <property name="delegate" ref="flatFileItemReader" />
</bean>
...
Run Code Online (Sandbox Code Playgroud)

像这样的三个豆子.

<bean id="database2" class="org.springframework.batch.item.database.JdbcCursorItemReader">
    <property name="name" value="database2Reader" />
    <property name="dataSource" ref="dataSource2" />
    <property name="sql" value="select image from object where image like '%/images/%'" />
    <property name="rowMapper">
        <bean class="sym.batch.ImagesRowMapper2" />
    </property>
</bean>
Run Code Online (Sandbox Code Playgroud)

java database spring spring-batch

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

使用Guava配置Spring缓存

关于缓存spring文档之后,我可以在我的项目中使用缓存,但是如何配置guava来定义每个缓存名称的过期时间或大小?

applicationConfig.xml

<bean id="cacheManager" class="org.springframework.cache.guava.GuavaCacheManager"/>
Run Code Online (Sandbox Code Playgroud)

Foo.java

@Cacheable(value="courses", key="#user.id")
public List<Course> getCoursesByUser(User user) {
    ...
}
Run Code Online (Sandbox Code Playgroud)

java spring caching guava

10
推荐指数
2
解决办法
2万
查看次数

如何做减号HQL

我有一个表A {id,foo,...}和一个表B {id,boo,idA}我想要A中的所有对象,其中ids没有出现在B中

在Oracle SQL中看起来像:

SELECT id FROM A MINUS( SELECT idA FROM B);
Run Code Online (Sandbox Code Playgroud)

database oracle hql

6
推荐指数
2
解决办法
4665
查看次数

Gradle 如何从 apk 中排除文件

我将密钥库存储在资产目录中。如何在构建中排除它以创建 .apk?

我以这种方式尝试过,但仍然存在:

android {
    ...
    packagingOptions {
            ...
            exclude 'META-INF/LICENSE.txt'
            ...
            exclude 'assets/keystore'
    }
}
Run Code Online (Sandbox Code Playgroud)

它排除LICENSE.txt但不排除keystore

android gradle

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

java.io.Image 到 InputStream

我正在调整图像大小,我需要返回一个 InputStream 对象

public InputStream resize(InputStream input, int maxSize){
   BufferedImage image = ImageIO.read(input);
   double scale = (double) image.getWidth()/maxSize;
   Image scaledImage = image.getScaledInstance( (int) (image.getWidth() * scale), (int) (image.getHeight() * scale), Image.SCALE_SMOOTH);
   InputStream ret = (InputStream) scaledImage;//this is wrong cast
   retrun ret;
}
Run Code Online (Sandbox Code Playgroud)

如何将图像转换为 InputStream?

java image inputstream

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

使用jsonPath检查Map键/值

我正在测试一个返回Map的控制器

@RequestMapping("/")
@ResponseBody
public Map<String, String> getMessages(@RequestBody String foo) {
    Map<String, String> map = boo.getMap(foo);
    return map;
}
Run Code Online (Sandbox Code Playgroud)

测试:

...
resultActions
        .andDo(print())
        .andExpect(status().isOk())
        .andExpect(
                content().contentTypeCompatibleWith(
                        MediaType.APPLICATION_JSON))
        .andExpect(jsonPath("$", notNullValue()))
        .andExpect(jsonPath(EXPRESSION, equalsTo(foo));
 ...
Run Code Online (Sandbox Code Playgroud)

我应该使用哪个表达式来读取Map中的键和值?

编辑:解决问题的方法可能是:

MvcResult result = resultActions.andReturn();
MockHttpServletResponse response = result.getResponse();
String content = response.getContentAsString();
Gson gson = new Gson();
Type typeOfT = new TypeToken<Map>() {
}.getType();
Map<String, String> map = gson.fromJson(content, typeOfT);
Run Code Online (Sandbox Code Playgroud)

然后遍历地图检查值.但有没有办法做到这一点jsonPath

java jsonpath mockmvc

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

使用Java在JSON中正确编写URL

我需要在JSON文档上写一个属性,这个属性是一个URL

这是我的代码:

String url = "http://localhost:1028/accumulate";
JSONObject cabecera = new JSONObject();
cabecera.put("reference", url);
Run Code Online (Sandbox Code Playgroud)

但是当我创建JSON时,这个属性就是以这种方式编写的:

"reference":"http:\/\/localhost:1028\/accumulate",
Run Code Online (Sandbox Code Playgroud)

所以,接收JSON字符串的服务,它发送给我一个错误:

<subscribeContextResponse>
  <subscribeError>
    <errorCode>
      <code>400</code>
      <reasonPhrase>Bad Request</reasonPhrase>
      <details>JSON Parse Error: <unspecified file>(1): invalid escape sequence</details>
    </errorCode>
  </subscribeError>
</subscribeContextResponse>
Run Code Online (Sandbox Code Playgroud)

写URL的正确方法是什么?

提前致谢

java string url json

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