如果我们在Spring Boot应用程序中使用eclipselink jpa,如何进行静态编织。互联网上缺乏足够的文章。我看到的文章使用了de.empulse.eclipselink staticweave-maven-plugin 用于 weave,但它已经有 10 年历史了,不知道它是否支持 Jpa 3 及更高版本。另一个问题是它对 persistence.xml 的要求。如何在 Spring Boot 中使用基于注释的方法。我尝试使用“map.put(PersistenceUnitProperties.WEAVING, "static");”,但它不编织。休息一切正常。
@Configuration
public class EclipsLinkJpaConfiguration extends JpaBaseConfiguration {
protected EclipsLinkJpaConfiguration(DataSource dataSource, JpaProperties properties,
ObjectProvider<JtaTransactionManager> jtaTransactionManager) {
super(dataSource, properties, jtaTransactionManager);
}
@Override
protected AbstractJpaVendorAdapter createJpaVendorAdapter() {
return new EclipseLinkJpaVendorAdapter();
}
@Override
protected Map<String, Object> getVendorProperties() {
Map<String, Object> map = new HashMap<>();
map.put(PersistenceUnitProperties.WEAVING, "static");
map.put(PersistenceUnitProperties.LOGGING_LEVEL, SessionLog.FINER_LABEL);
//map.put(PersistenceUnitProperties.DDL_GENERATION, PersistenceUnitProperties.CREATE_ONLY);
// map.put(PersistenceUnitProperties.LOGGING_LEVEL, SessionLog.FINER_LABEL);
map.put(PersistenceUnitProperties.BATCH_WRITING, "JDBC");
return map;
}
@Bean
public static DataSource dataSource() {
final DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
dataSource.setUrl("jdbc:mysql://localhost:3306/studentcrudangular");
dataSource.setUsername("root");
dataSource.setPassword("root");
return dataSource;
}
}
静态编织是在编译后为您提供一组新的类文件而执行的操作。此设置/提示指定 jar 文件已经被编织,以便 EclipseLink 知道它们应该已经被增强并且能够使用高级功能,例如一对一的延迟加载。请参阅 https://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Performance/Weaving/Static_Weaving