我正在尝试在Mac上的捆绑包中加载Qt5文件。
public class JobPerson {
@Autowired
private JobBuilderFactory jobs;
@Autowired
private StepBuilderFactory steps;
@Bean
public ItemReader<Person> itemReader() {
FlatFileItemReader<Person> reader = new FlatFileItemReader<Person>();
reader.setResource(new ClassPathResource("user.csv"));
reader.setLineMapper(new DefaultLineMapper<Person>() {{
setLineTokenizer(new DelimitedLineTokenizer(";") {{
setNames(new String[] {"firstName", "lastName", "age" });
}});
setFieldSetMapper(new BeanWrapperFieldSetMapper<Person>() {{
setTargetType(Person.class);
}});
}});
return reader;
}
@Bean
public ItemWriter<Person> itemWriter() {
return items -> {
int i=0;
for (Person item : items) {
i++;
System.out.println(i+". Nom = " + item.getFirstName()+". Prenom = " + item.getLastName());
}
};
}
@Bean
public ItemProcessor<Person, Person> itemProcessor() {
return item -> {
String stritem=item.toString();
String[] splitArray = stritem.split(";"); // tableau de chaînes
int lineData = splitArray.length;
//if (lineData<2)
if (item.equals("Eric")) {
throw new IllegalArgumentException("Wanted!");
}
return item;
};
}
@Bean
public Step step() {
return steps.get("step")
.<Person, Person>chunk(5)
.reader(itemReader())
.processor(itemProcessor())
.writer(itemWriter())
.faultTolerant()
.skip(IllegalArgumentException.class)
.skipLimit(100)
.listener(new MySkipListener())
.skip(Exception.class)
.build();
}
@Bean
public Job job() {
return jobs.get("job")
.start(step())
.build();
}
public static class MySkipListener implements SkipListener<Person, Person> {
@Override
public void onSkipInRead(Throwable t) {
System.err.println("On Skip in Read Error : " + t.getMessage());
}
@Override
public void onSkipInWrite(Person item, Throwable t) {
System.out.println("Item " + item + " was skipped due to: " + t.getMessage());
}
@Override
public void onSkipInProcess(Person item, Throwable t) {
System.out.println("Item " + item + " was skipped due to: " + t.getMessage());
}
}
}
这在命令行中可以正常工作,但是当我将其与pyinstaller捆绑在一起时,该程序将中止,因为它找不到文件mainUI.ui。我找到了this solution,但无法正常运行(找不到resource_path函数)。 我做了另一个,但效果很好,但是这个(一个文件程序)我无法工作。
编辑: 我停止尝试解决此问题,转而使用多文件解决方案:1个文件用于启动,一个文件用于PyQt函数。可行100%。