[英]How to enable the eclipselink static weaving in spring boot along with gradle
@Configuration
public class JpaConfig extends JpaBaseConfiguration {
protected JpaConfig(DataSource dataSource, JpaProperties properties,
ObjectProvider<JtaTransactionManager> jtaTransactionManagerProvider,
ObjectProvider<TransactionManagerCustomizers> transactionManagerCustomizers) {
super(dataSource, properties, jtaTransactionManagerProvider, transactionManagerCustomizers);
}
@Override
protected AbstractJpaVendorAdapter createJpaVendorAdapter() {
return new EclipseLinkJpaVendorAdapter();
}
@Override
protected Map<String, Object> getVendorProperties() {
final HashMap<String, Object> props = new HashMap<>();
props.put(PersistenceUnitProperties.WEAVING, detectWeavingMode());
return props;
}
private String detectWeavingMode() {
return "static";
}
/**
*
* @param entityManagerFactory
* @return
*/
@Bean
public PlatformTransactionManager transactionManager(final EntityManagerFactory entityManagerFactory) {
final JpaTransactionManager transactionManager = new JpaTransactionManager();
transactionManager.setEntityManagerFactory(entityManagerFactory);
return transactionManager;
}
}
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "gradle.plugin.org.jamgo:eclipselink-plugin:0.2.2"
}
}
apply plugin: "org.jamgo.eclipselink-plugin"
我不確定這個插件及其功能,但是如果沒有插件,純 Gradle 是可能的。
要完成這項工作,需要執行 3 個步驟:
persistence.xml
文件,以避免類路徑上重復的persistence.xml
沖突此外,將流程連接到 compileJava 任務的最后一步非常重要,以免破壞 Gradle 的最新檢查。
更詳細的解釋可以看我在上面的文章: EclipseLink static weaving with Gradle 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.