小编Vij*_*ayD的帖子

自弃用以来替换@SequenceGenerator

我有一个问题@SequenceGenerator:

@SequenceGenerator(name="pk_user_id", sequenceName="seq_user_id", allocationSize=1)
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="pk_user_id")
Run Code Online (Sandbox Code Playgroud)

应用程序启动时会显示警告:

WARN 7388 --- [main] org.hibernate.orm.deprecation:HHH90000014:发现使用不推荐的[org.hibernate.id.SequenceHiLoGenerator]基于序列的id生成器; 请改用org.hibernate.id.enhanced.SequenceStyleGenerator.有关详细信息,请参阅"休眠域模型映射指南"

我试图找出如何用新的代码替换已弃用的代码,但找不到任何解决方案.

java hibernate sequence-generators

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

具有URL编码数据的Spring RestTemplate POST请求

我是Spring的新手,并试图用RestTemplate做一个休息请求.Java代码应该像下面的curl命令一样:

curl --data "name=feature&color=#5843AD" --header "PRIVATE-TOKEN: xyz" "https://someserver.com/api/v3/projects/1/labels"
Run Code Online (Sandbox Code Playgroud)

但是服务器用一个拒绝RestTemplate 400 Bad Request

RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.add("PRIVATE-TOKEN", "xyz");
HttpEntity<String> entity = new HttpEntity<String>("name=feature&color=#5843AD", headers);
ResponseEntity<LabelCreationResponse> response = restTemplate.exchange("https://someserver.com/api/v3/projects/1/labels", HttpMethod.POST, entity, LabelCreationResponse.class);
Run Code Online (Sandbox Code Playgroud)

谁能告诉我我做错了什么?

java spring spring-web

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

如何使用Restful api在Spring中自动修剪bean对象的字符串?

我想自动修剪所有表单字符串字段修剪(仅限尾随和前导空格)

假设我通过FirstName ="robert"预期:"robert"

控制器类具有以下代码:

@InitBinder
public void initBinder ( WebDataBinder binder )
{
    StringTrimmerEditor stringtrimmer = new StringTrimmerEditor(true);  
    binder.registerCustomEditor(String.class, stringtrimmer);
}

@RequestMapping(value = "/createuser", method = RequestMethod.POST)
public Boolean createUser(@RequestBody  UserAddUpdateParam userAddUpdateParam) throws Exception {

    return userFacade.createUser(userAddUpdateParam);
}  
Run Code Online (Sandbox Code Playgroud)

当我调试代码时,它进入@InitBinder而不是修剪bean类字符串字段.

java rest spring

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

XPTY0004:'>'的第一个操作数的必需项类型是数字; 提供的值具有项类型xs:string

toComplie字符串包含函数的所有定义,如sum,multiply等附加 if ($a > 0) then (iaf:numeric-equal(iaf:numeric-multiply($b, $c), $d)) else (true())

执行此操作的代码段是:

XQueryExecutable queryExecutable = xqueryCompiler.compile(toCompile.toString());
XQueryEvaluator xqueryEvaluator = queryExecutable.load();

//setExternalVariables(): function used to set the variables for the test contains below line
        xqueryEvaluator.setExternalVariable(new QName(memberName), value);
setExternalVariables(xqueryEvaluator,assertionExpression);

xqueryResult = xqueryEvaluator.evaluate();
Run Code Online (Sandbox Code Playgroud)

抛出异常如下:

XPTY0004:'>'的第一个操作数的必需项类型是数字; 提供的值具有项类型xs:string


如果需要更多信息来了解这个问题,请告诉我.这是因为其他部分还是别的什么?

编辑:在setExternalVariables(),我使用for-each循环使用下面的行添加变量.value变量是类型net.sf.saxon.s9api.XdmValue

xqueryEvaluator.setExternalVariable(new QName(memberName), value);
Run Code Online (Sandbox Code Playgroud)

setExternalVariables()方法中,

// FACT_VALUE_FORMAT:%s;%s --  where first string is value and second gives information about precision.
//current option
XdmAtomicValue atomicValue = new XdmAtomicValue(String.format(FACT_VALUE_FORMAT, fact.getValue(),getPrecision(fact.getDecimals())));
// alternative …
Run Code Online (Sandbox Code Playgroud)

java xml xquery saxon xbrl

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

用于查询XSD文件的Java方法

我有一组用于不同数据类型的xsd文件.在Java世界中,生成类型属性列表的最佳方法是什么?

例如,这两个文件.

file:customer.xsd

<?xml version="1.0" encoding="ISO-8859-1" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="customer">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="number" type="xs:integer"/>
      <xs:element name="name" type="xs:string"/>
      <xs:element name="address" type="xs:string"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>
</xs:schema>
Run Code Online (Sandbox Code Playgroud)

file:order.xsd

<?xml version="1.0" encoding="ISO-8859-1" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="customer">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="orderid" type="xs:integer"/>
      <xs:element name="customer" type="xs:string"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>
</xs:schema>
Run Code Online (Sandbox Code Playgroud)

我想做两件事

1.一个Java应用程序,它读入XSD并进行处理(不知何故?).因此,当您运行该程序时,它可以打印出属性

> java -jar printtypes.jar -f customer.xsd
> number : Integer
> name : String
> address : String
Run Code Online (Sandbox Code Playgroud)

2.某种生成新文件的转换

file:customer.properties

<propertylist>
<prop>
 <name> orderid </name>
 <type> integer </type>
</prop> …
Run Code Online (Sandbox Code Playgroud)

java xml xsd

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

快照代理不起作用

我尝试使用以下命令在Ubuntu 18.04虚拟机上安装Conjure-Up

$sudo snap install conjure-up --classic
Run Code Online (Sandbox Code Playgroud)

但它总是说:

错误:无法安装“ conjure-up”:发布https://api.snapcraft.io/v2/snaps/refresh:proxyconnect tcp:EOF

我已经成功地建立了我的HTTPHTTPS代理/etc/environments

需要帮忙。

proxy sudo ubuntu-18.04

5
推荐指数
2
解决办法
6532
查看次数

如何在JSP中迭代地图?

如何<Integer, List<ResponseInfo>>使用<c:forEach>JSTL标记在JSP中迭代map,然后使用另一个for循环迭代该列表?

如果您想查看代码,请告诉我.

从控制器我回来了
return new ModelAndView("reviewAudit","responseForm",responseForm);

其中responseForm包含一个地图:
private Map<String, List<ResponseInfo>> resInfoMap;


这是我的JSP代码:

<div class="panel-body">
    <div class="panel-group" id="accordion">
    <c:forEach items="${responseForm.resInfoMap}" var="responselist">

        <div class="panel panel-primary">
            <div class="panel-heading">
                <h4 class="panel-title">
                    <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" class="">Topic1</a>
                </h4>
            </div>
            <div id="collapseOne" class="panel-collapse collapse in" aria-expanded="true">
                <div class="panel-body">
                    <table>
                        <c:forEach items="${responselist}" var="response1">
                        <tr>
                            <td>
                                <p>
                                    <span style="font-size: 13px; font-weight: bold;">Q:</span>
                                    ${response1.auditQuestion}
                                </p>
                            </td>
                            <td>
                                <p>
                                    <span style="font-size: 13px; font-weight: bold;">Ans:</span>
                                    ${response1.auditResponse}
                                </p>
                                <p>
                                    <span style="font-size: 13px; …
Run Code Online (Sandbox Code Playgroud)

java foreach jsp jstl

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

无法使用Saxon处理器应用区间运算

我正在使用Saxon处理器来执行验证.
包含所有函数定义的文件如下:
default-definition.txt:

declare variable $a external; 
declare variable $b external; 
declare variable $c external; 

declare function iaf:sum(
$params as item()*
) as item()+ {

  let $facts := if (empty($params)) then (0) else one-or-more($params)
  let $values := for $i in $facts return (iaf:splitValueThreshold($i)[1])
  let $thresholds := for $i in $facts return (iaf:splitValueThreshold($i)[2])
  let $sumValues := sum($values)
  let $sumThresholds := sum($thresholds)
  let $output := iaf:joinValueThreshold($sumValues, $sumThresholds) 
       return ($output)

};

declare function iaf:numeric-equal(
$paramA as item(), $paramB as item() …
Run Code Online (Sandbox Code Playgroud)

java xml xquery saxon xbrl

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

如何检查/测试应用程序是否未在浏览器上缓存?

我已经写了一个class CacheControlFilter implements javax.servlet.Filter to set header 来确保应用程序没有缓存。也已经在 web.xml 中完成了输入

<filter>
    <filter-name> Cache controller filter</filter-name>
    <filter-class>com.filter.CacheControlFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>Cache controller filter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
Run Code Online (Sandbox Code Playgroud)

请建议我如何检查/测试这是否有效?如果您想了解更多信息,请告诉我。

java spring caching cache-control browser-cache

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