小编Jav*_*rez的帖子

Spring Data Elasticsearch的@Field注释无法正常工作

我在pom.xml中有一个带有Spring Data Elasticsearch插件的Spring Boot应用程序.我创建了一个文档类,我想索引:

@Document(indexName = "operations", type = "operation")
public class OperationDocument {

@Id
private Long id;

@Field(
    type = FieldType.String, 
    index = FieldIndex.analyzed, 
    searchAnalyzer = "standard", 
    indexAnalyzer = "standard",
    store = true
)
private String operationName;

@Field(
    type = FieldType.Date, 
    index = FieldIndex.not_analyzed, 
    store = true, 
    format = DateFormat.custom, pattern = "dd.MM.yyyy hh:mm"
)
private Date dateUp;

@Field(
    type = FieldType.String, 
    index = FieldIndex.not_analyzed, 
    store = false
) 
private String someTransientData;

@Field(type = FieldType.Nested)
private List<Sector> sectors;

//Getter …
Run Code Online (Sandbox Code Playgroud)

elasticsearch spring-data spring-data-elasticsearch

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

杰克逊将单个项目反序列化为列表

我正在尝试使用一个服务,它为我提供了一个具有字段的实体,它是一个数组.

{
  "id": "23233",
  "items": [
    {
      "name": "item 1"
    },
    {
      "name": "item 2"
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)

但是当数组包含单个项时,将返回项本身,而不是一个元素的数组.

{
  "id": "43567",
  "items": {
      "name": "item only"
    }
}
Run Code Online (Sandbox Code Playgroud)

在这种情况下,杰克逊无法转换为我的Java对象.

public class ResponseItem {

   private String id;
   private List<Item> items;

   //Getters and setters...
}
Run Code Online (Sandbox Code Playgroud)

有一个简单的解决方案吗?

java json jackson

8
推荐指数
2
解决办法
7178
查看次数

Thymeleaf没有解析"sec:authorize"属性

我正在使用thymeleaf-spring3 2.0.18Spring 3.1.1.我已经完成了一个工作正常的登录页面,但是,在解析其他Thymeleaf属性时,"sec:authorize"不是,因为如果我查看生成的视图的源代码,我可以看到它们.

是否有我缺少的东西,如依赖或特定配置?

这是我的login.html:

<!DOCTYPE html>
<head>
...
</head> 

<body>
<div class="top">
    <div class="container">         
        <ul class="loginbar pull-right">
            <li sec:authorize="isAnonymous()"><a href="/login" class="login-btn">Login</a></li>   
            <li sec:authorize="isAuthenticated()" class="login-btn">Welcome <span sec:authentication="name">Bob</span></li>   
        </ul>
    </div>      
</div><!--/top-->

<!--=== Content Part ===-->
<div class="container">     
    <div class="row-fluid">
        <form name="f" th:action="@{/j_spring_security_check}" method="post" class="log-page">
            <h3>Login</h3>
            <div th:if="${loginError}" th:with="errorMsg=${session['SPRING_SECURITY_LAST_EXCEPTION'].message}" class="alert alert-error">
                Bad user or password.<br/>
                Cause: <span th:text="${errorMsg}">Wrong input!</span>
            </div>    
            <div class="input-prepend">
                <span class="add-on"><i class="icon-user"></i></span>
                <input name="j_username" class="input-xlarge" type="text" placeholder="Username" />
            </div>
            <div class="input-prepend">
                <span class="add-on"><i class="icon-lock"></i></span>
                <input …
Run Code Online (Sandbox Code Playgroud)

spring-mvc spring-security thymeleaf

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