小编Lan*_*ana的帖子

在基于flyway java的迁移中不会注入Spring bean

我试图在flyway迁移java代码中注入配置属性的组件,但它总是为null.

我和Flyway一起使用弹簧靴.

@Component
@ConfigurationProperties(prefix = "code")
public class CodesProp {

    private String codePath;
 }
Run Code Online (Sandbox Code Playgroud)

然后在Flyway迁移代码中,尝试按如下方式自动执行此组件:

public class V1_4__Migrate_codes_metadata implements SpringJdbcMigration {

@Autowired
private CodesProp codesProp ;
public void migrate(JdbcTemplate jdbcTemplate) throws Exception {
    codesProp.getCodePath();  
}
Run Code Online (Sandbox Code Playgroud)

在这里,codesProp始终为null.

有没有办法在飞路中注入弹簧豆或在飞路豆之前进行初始化?

谢谢.

spring flyway spring-boot

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

Java 8 Stream groupingby 不返回列表

有没有办法Map<Long, String>直接从groupingByJava 8 中的函数创建,而不是创建Map<Long, Set<String>>

我有以下代码:

List<Object[]> list = new ArrayList<>();
//row[0] is the primary key and row[1] is the name of the employee
Object[] input1 = { 1l, "employee1",  null};
Object[] input2 = { 1l, "employee1", "vorw2"};
Object[] input3 = { 2l, "employee2", "vorw3"};
Object[] input4 = { 3l, "employee3", "vorw1"};
list.add(input1);
list.add(input2);
list.add(input3);
list.add(input4);

//code to replaced
Map<String, Set<String>> byPK= list.stream().collect(Collectors.groupingBy(row -> row[0].longValue(), Collectors.mapping(row -> row[1].toString(),Collectors.toSet() )));
Run Code Online (Sandbox Code Playgroud)

我需要像这样的 o/p:

List ==> (1l, …
Run Code Online (Sandbox Code Playgroud)

java java-8 java-stream

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

标签 统计

flyway ×1

java ×1

java-8 ×1

java-stream ×1

spring ×1

spring-boot ×1