小编use*_*618的帖子

测试套件运行一次Spring Boot

我正在尝试创建一个在套件开始时运行Spring Boot的测试套件.我有它的工作,每个测试用例都有@SpringBootTest,但我想在测试套件中只有@SpringBootTest.

我确实看到了这个,但没有提到@RunWith Suite.class.

spring test-suite spring-boot

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

React 功能组件继承

我创建了一个 React 功能组件,它是 react-data-grid 组件的包装器。现在我需要一个完全相同的第二个组件,除了一个函数(如果您熟悉 react-data-grid,则为 rowGetter。)

我在 Intranet 上工作,所以我将输入一个快速示例...

function UsersInfoDataTable(props) {

  const userInfoCols = [
    {key: "a", name: "A", ...},
    {key: "b", name" "B", ...},
    {key: "c", name" "C", ...},
    ...
  ];

  const aCellCreation = (aData, description, index) => (
    <span title={...}>...</span>
  )

  const bCellCreation = (bData, index) => (
    <div className={...}>...</div>
  }

  ...

  
  const formattedTableData = props.myData.map(function (obj, index) {
    //do some stuff
    return {"a": aCellCreation(obj.a, obj.desc,index), "b": bCellCreation(obj.b, index), ...}
  });

  const rowGetter = rowNumber => …
Run Code Online (Sandbox Code Playgroud)

code-reuse components functional-programming reactjs

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

Spring Repository PreAuthorize 给出“无法评估表达式”错误

我添加了很多粗体,因为有人降级了我的问题,我认为这很奇怪......

我从这个工作开始,这意味着 @PreAuthorize 的配置正确...

@RestController
@RequestMapping('/people')
public PersonController extends BaseController {
   @PreAuthorize("#pesonId != principal.id")
   @RequestMapping(value="updatePerson", method={RequestMethod.POST}, produces = MediaType.APPLICATION_JSON_VALUE)
   public @ResponseBody SimpleResponseStatus updatePerson(@RequestParam(personId) final Long personId, @RequestParam(value) final String value, final HttpServerRequest request, final HttpServletResponse response)
   {
      Person p = personRepo.findById(personId);
      p.setValue(value);
      personRepo.save(p);
   }
}
Run Code Online (Sandbox Code Playgroud)

并移至此不起作用...存储库中的@PreAuthorize save()...

public interface PersonRepository extends JpaRepository<Person,Long> {

  @SuppressWarnings("unchecked")
  @Override
  @PreAuthorize("#p.id != principal.id")
  Person save(person p);

}
Run Code Online (Sandbox Code Playgroud)

现在我得到一个“无法评估表达式'#p.id!=principal.id'

在控制器上工作时的一个区别是我做了#personId而不是#p.id,所以我不知道表达式中的对象与基元是否是问题,或者控制器与存储库(我在其中进行评估)是否有问题是问题所在。

所以我有几个问题...

  1. 我是否需要做一些特殊的事情才能使预授权在存储库中正常工作?

  2. 与 Spring 安全无关,但为什么我被迫添加 SuppressWarnings?我可以看看我是否会回来,List<Person>但我觉得这很奇怪。

  3. 还有另一个例子,我想要执行一个 PreAuthorize 表达式,如“#p.group.id != 3”...评估中的级别是否有限制?即级别 = obj.obj.obj.obj.value …

spring spring-security

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