我试图在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.
有没有办法在飞路中注入弹簧豆或在飞路豆之前进行初始化?
谢谢.
有没有办法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)