小编jan*_*lan的帖子

如何使用 Hibernate 正确映射 MonetaryAmount?

当我尝试将自定义 Expenditure 对象映射到 MySQL 中的关系模型时,出现错误:

Initial SessionFactory creation failed.org.hibernate.MappingException: Could not determine type for: javax.money.MonetaryAmount, at table: Expenditure, for columns: [org.hibernate.mapping.Column(monetaryAmount)]
Run Code Online (Sandbox Code Playgroud)

我的支出类别:

@Entity
public class Expenditure implements Comparable<Expenditure> {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Integer id;

    private String description;

    private MonetaryAmount monetaryAmount;

    private LocalDate date;

    private ExpenditureType type;

    @OneToOne
    private User client;
...
}
Run Code Online (Sandbox Code Playgroud)

在这种情况下如何进行映射?

java spring jpa java-8 spring-data-jpa

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

从Moment.js对象获取小时,分钟,秒

我想知道是否可以从Moment对象获取小时,几分钟和几秒钟?

例如:

Moment('12:16','HH:mm').get('minutes') //should result in '16'
Run Code Online (Sandbox Code Playgroud)

我在文档中找不到类似的东西...

javascript node.js momentjs

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

Spring Boot REST API 接受所有请求并返回空白响应

当使用 Postman 或从 Angular 前端发出请求时,200 OK即使在错误的路线上,我总是从后端得到空白/空响应。

安全配置:

    @Override
    protected void configure(HttpSecurity http) throws Exception {

        http.csrf().disable()
                .authorizeRequests()
                .antMatchers("/public/**").permitAll()
                .anyRequest().authenticated()
                .and()
                .sessionManagement()
                .sessionCreationPolicy(SessionCreationPolicy.STATELESS);
        http.addFilterBefore(jwtRequestFilter, UsernamePasswordAuthenticationFilter.class);

    }
Run Code Online (Sandbox Code Playgroud)

例如,检查用户名是否被占用:

    @GetMapping("/available")
    public Boolean isUsernameTaken(@RequestParam String username) {
        return userService.isUsernameTaken(username);
    }
Run Code Online (Sandbox Code Playgroud)

甚至没有进入这个方法,但返回的代码是200.

在错误的端点上发出请求http://localhost:8080/fakeEndpoint/xxxxx也会返回空白页和代码 200。

java rest spring-security spring-boot

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