小编Jef*_*eff的帖子

无法从 String 值实例化 [简单类型,类 java.time.LocalDate] 类型的值

我有一个这样的课程:

@Data
@NoArgsConstructor(force = true)
@AllArgsConstructor(staticName = "of")
public class BusinessPeriodDTO {
    @DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
    LocalDate startDate;
    @DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
    LocalDate endDate;
}
Run Code Online (Sandbox Code Playgroud)

我在另一个类中使用了这个类,我们称之为 PurchaseOrder

@Entity
@Data
@NoArgsConstructor(access = AccessLevel.PROTECTED, force = true)
public class PurchaseOrder {
    @EmbeddedId
    PurchaseOrderID id;

    @Embedded
    BusinessPeriod rentalPeriod;

    public static PurchaseOrder of(PurchaseOrderID id, BusinessPeriod period) {
        PurchaseOrder po = new PurchaseOrder();
        po.id = id;

        po.rentalPeriod = period;

        return po;
    }
Run Code Online (Sandbox Code Playgroud)

我正在尝试使用 jakson 和这个 JSON 填充 purchaseOrder 记录:

 {
     "_class": "com.rentit.sales.domain.model.PurchaseOrder",
     "id": 1,
     "rentalPeriod": {
         "startDate": …
Run Code Online (Sandbox Code Playgroud)

java spring

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

编织错误。找不到对象

我有一个未清理的数据集。因此,我已经将其导入到我的R studio中。然后nrow(adult)在rmarkdown文件中运行并按下ctrl+Enter它时可以正常工作,但是当我按下时knit出现以下错误:

在此处输入图片说明

r

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

Plotly:如何将轴布局添加到子图中?

鉴于我有来自此链接的以下代码:

from plotly.subplots import make_subplots
import plotly.graph_objects as go

fig = make_subplots(rows=1, cols=2)

fig.add_trace(
    go.Scatter(x=[1, 2, 3], y=[4, 5, 6]),
    row=1, col=1
)

fig.add_trace(
    go.Scatter(x=[20, 30, 40], y=[50, 60, 70]),
    row=1, col=2
)

fig.update_layout(height=600, width=800, title_text="Subplots")
fig.show()
Run Code Online (Sandbox Code Playgroud)

这段代码的问题是,xaxisyaxis没有任何标签。除此之外,当前代码仅对所有图应用一个标题,但是我想对每个散点图应用不同的标题

我怎样才能做到这一点?

python subplot plotly

4
推荐指数
2
解决办法
7057
查看次数

org.h2.jdbc.JdbcSQLException:方法仅允许查询

我使用以下代码在我的数据库上运行查询.

@Repository
public interface PurchaseOrderRepository extends JpaRepository<PurchaseOrder, PurchaseOrderID> {

    @Query(value ="update PURCHASE_ORDER   set status='REJECTED'   where id=?1", nativeQuery = true)
    void RejectPO(Long id);
}
Run Code Online (Sandbox Code Playgroud)

然后我只是在服务中调用此方法

@Service
public class SalesService {

    @Autowired
    PurchaseOrderRepository purchaseOrderRepository;
public void RejectPurchaseOrder(Long of) {

        purchaseOrderRepository.RejectPO(of);
    }
}
Run Code Online (Sandbox Code Playgroud)

但我面临一个错误:

org.h2.jdbc.JdbcSQLException: Method is only allowed for a query. Use execute or executeUpdate instead of executeQuery; SQL statement:
update PURCHASE_ORDER   set status='REJECTED'   where id=? [90002-191]
Run Code Online (Sandbox Code Playgroud)

问题是,我从来没有打电话executeQuery,我只是要求使用它来运行它jpa.那么我该如何解决呢?

java spring jpa

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

java spring:意外令牌:*

在我的jpa界面中,我有以下代码:

public interface ConsultationRequestRepository extends CrudRepository<ConsultationRequest, Integer> {

    @Query("select * from ConsultationRequest where status = ?1")
    List<ConsultationRequest> findRequestsByStatus(ConsultationStatus status);
}
Run Code Online (Sandbox Code Playgroud)

但它抱怨错误:

antlr.NoViableAltException: unexpected token: *
Run Code Online (Sandbox Code Playgroud)

这段代码有什么问题?

java spring

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

反应:延迟更新状态

请考虑以下代码.我想保持文本字段中文本的最后一个字符存储在一个名为的状态lastChar.为此,我做了以下代码?

define(["react","react-keydown"], (React,keydown) => {

  var TypingContainer = React.createClass({
    getInitialState: function() {
      return {text: '',lastChar:''};
    },
    handleChange: function(e) {


          console.log('lastChar typed is:'+ e.target.value.slice(-1));

          this.setState({lastChar: e.target.value.slice(-1)});

          console.log('lastChar in state is:'+ this.state.lastChar);


    }

      ,
    render: function() {
      return(
         <div>
           {this.props.candidateWord}
           {this.props.message}
            <input
              className="typing-container"
              value={this.state.message}
              onChange={this.handleChange}



            />

         </div>
      );
    }
  })
  return TypingContainer;
});
Run Code Online (Sandbox Code Playgroud)

例如,如果用户输入hello,我希望看到两者中的最后一个字符,e.target.value.slice(-1)并且this.state.lastChar相同o

同时lastChar显示l

换句话说,lastChar在精确值之前总是一个char?

为什么会这样?我该如何解决?

reactjs

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

React:按下空格时重置输入值

我是反应新手。""在我的反应组件中,我有一个输入,我需要在用户按下时将输入的值重置为space button。您可以将该组件视为如下:

import React,{Component} from 'react';

export default class InputReceiver extends Component{

      render(){
          return(
            <div className="col-sm-10">
              <input type="text" className="form-control" onChange={this.props.inputHandler}/>
            </div>);
      }

}
Run Code Online (Sandbox Code Playgroud)

我必须在 中做到这一点,这是真的吗action?但动作不明白了input

要点: 我不应该使用 jQuery。

reactjs react-redux

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

无法绑定到'uploader',因为它不是'div'的已知属性

我正在尝试使用库上传angular2 CR5打字稿中的文件.我正在使用棱角分明 "version": "1.0.0-beta.16"

所以,首先我

npm i ng2-file-upload --save
Run Code Online (Sandbox Code Playgroud)

在我有的组件:

import { Component } from '@angular/core';
import { FileUploader } from 'ng2-file-upload';

// const URL = '/api/';
const URL = 'https://evening-anchorage-3159.herokuapp.com/api/';

@Component({
  selector: 'app-simple-demo',
  templateUrl: './simple-demo.component.html',
  styleUrls: ['./simple-demo.component.css']
})
export class SimpleDemoComponent {
  public uploader:FileUploader = new FileUploader({url: URL});
  public hasBaseDropZoneOver:boolean = false;
  public hasAnotherDropZoneOver:boolean = false;

  public fileOverBase(e:any):void {
    this.hasBaseDropZoneOver = e;
  }

  public fileOverAnother(e:any):void {
    this.hasAnotherDropZoneOver = e;
  }
}
Run Code Online (Sandbox Code Playgroud)

组件的html端的一部分是:

          <div ng2FileDrop
                 [ngClass]="{'nv-file-over': hasBaseDropZoneOver}"
                 (fileOver)="fileOverBase($event)" …
Run Code Online (Sandbox Code Playgroud)

typescript angular

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

Spring-Security:MySQL JDBC身份验证失败

我在这个仓库中操纵一个开源项目.该文件bank.sql是mysql中数据库的模式.这是pom.xml:

 <dependencies>

    <!-- https://mvnrepository.com/artifact/org.apache.tomcat/juli -->
    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>juli</artifactId>
        <version>6.0.26</version>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.0</version>
        <scope>provided</scope>
    </dependency>


     <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
        <scope>provided</scope>
    </dependency>

  <dependency>
   <groupId>junit</groupId>
   <artifactId>junit</artifactId>
   <version>4.11</version>
   <scope>test</scope>
  </dependency>

  <dependency>
     <groupId>org.springframework</groupId>
     <artifactId>spring-core</artifactId>
     <version>3.2.3.RELEASE</version>
  </dependency>

  <dependency>
     <groupId>org.springframework</groupId>
     <artifactId>spring-web</artifactId>
     <version>3.2.3.RELEASE</version>
  </dependency>

  <dependency>
     <groupId>org.springframework</groupId>
     <artifactId>spring-webmvc</artifactId>
     <version>3.2.3.RELEASE</version>
  </dependency>

  <dependency>
      <groupId>org.springframework.security</groupId>
      <artifactId>spring-security-core</artifactId>
      <version>3.2.3.RELEASE</version>
  </dependency>

  <dependency>
      <groupId>org.springframework.security</groupId>
      <artifactId>spring-security-config</artifactId>
      <version>3.2.3.RELEASE</version>
  </dependency>

  <dependency>
       <groupId>org.springframework.security</groupId>
       <artifactId>spring-security-web</artifactId>
       <version>3.2.3.RELEASE</version>
  </dependency>

  <dependency>
       <groupId>org.springframework</groupId>
       <artifactId>spring-jdbc</artifactId>
       <version>3.2.3.RELEASE</version>
  </dependency>

  <dependency>
       <groupId>mysql</groupId>
       <artifactId>mysql-connector-java</artifactId>
       <version>5.1.6</version>
  </dependency>

  <dependency>
       <groupId>jstl</groupId>
       <artifactId>jstl</artifactId>
       <version>1.2</version>
  </dependency>

  <dependency> …
Run Code Online (Sandbox Code Playgroud)

java jsp spring-security

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

检查 NumPy 数组的所有元素是否符合条件

对于给定的二维数组,如下所示,我需要检查所有元素是否小于 0.2。

a = np.array([[0.26002, 0.13918, 0.6008 ],
              [0.2997 , 0.28646, 0.41384],
              [0.41614, 0.36464, 0.21922]])
Run Code Online (Sandbox Code Playgroud)

这是我的代码,基于这个问题

 res = abs(a<0.2)
 all(i==True for i in res)
Run Code Online (Sandbox Code Playgroud)

但是代码抱怨

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Run Code Online (Sandbox Code Playgroud)

python numpy conditional-statements

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