전체 코드는 on GitHub입니다.MetaDataException : "* .CustomerEntity"유형이 향상되지 않았습니다. Spring-JPA 및 OpenJPA를 사용하여 행을 만들려고 시도합니다.
는 주요 코드 (엔티티 및 저장소 클래스는 생략) 다음과됩니다 :
package org.inthemoon.tests.tryspringjpaplushibernate;
import org.apache.commons.dbcp2.BasicDataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.*;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.JpaVendorAdapter;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.Database;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter;
import org.springframework.stereotype.Component;
import org.springframework.transaction.PlatformTransactionManager;
import java.io.File;
/**
* Created by Dims on 13.01.2017.
*/
public class Main {
@Configuration
@Import(Service.class)
@EnableJpaRepositories("org.inthemoon.tests.tryspringjpaplushibernate")
public static class _Config {
@Bean
File programDirectory() {
File ans = new File(".");
return ans;
}
@Bean
BasicDataSource dataSource() {
BasicDataSource ans = new BasicDataSource();
ans.setDriverClassName("org.h2.Driver");
File databasePath = new File(programDirectory(), "data\\tryspringjpaplushibernate");
ans.setUrl("jdbc:h2:file:" + databasePath.getAbsolutePath());
return ans;
}
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
LocalContainerEntityManagerFactoryBean ans =
new LocalContainerEntityManagerFactoryBean();
ans.setDataSource(dataSource());
ans.setJpaVendorAdapter(jpaVendorAdapter());
ans.setPackagesToScan(getClass().getPackage().getName());
return ans;
}
@Bean
public JpaVendorAdapter jpaVendorAdapter() {
OpenJpaVendorAdapter ans = new OpenJpaVendorAdapter();
ans.setShowSql(false);
ans.setGenerateDdl(true);
ans.setDatabase(Database.H2);
return ans;
}
@Bean
public PlatformTransactionManager transactionManager() {
JpaTransactionManager ans = new JpaTransactionManager();
ans.setEntityManagerFactory(entityManagerFactory().getObject());
return ans;
}
}
@Component
public static class Service {
private final CustomerRepo customerRepo;
@Autowired
public Service(CustomerRepo customerRepo) {
this.customerRepo = customerRepo;
}
public void doSomeOperation() {
CustomerEntity customer = new CustomerEntity();
customer.setId(1);
customer.setNam("New Customer");
customerRepo.deleteAll();
customerRepo.save(customer);
}
}
public static void main(String[] args) {
ApplicationContext context = new AnnotationConfigApplicationContext(_Config.class);
Service service = context.getBean(Service.class);
service.doSomeOperation();
}
}
컨텍스트를 초기화하는 예외가 발생 이름 'customerRepo'와 콩을 만드는
,536,913 동안 빈에 'jpaMappingContext을' 를 참조 확인할 수 없음 내가 뭘 잘못했는지오류 말 : 설정 빈 속성 'mappingContext'
Caused by: <openjpa-2.4.2-r422266:1777108 fatal user error> org.apache.openjpa.util.MetaDataException: The type "class org.inthemoon.tests.tryspringjpaplushibernate.CustomerEntity" has not been enhanced.
at org.apache.openjpa.meta.ClassMetaData.resolveMeta(ClassMetaData.java:1834)
at org.apache.openjpa.meta.ClassMetaData.resolve(ClassMetaData.java:1808)
at org.apache.openjpa.meta.MetaDataRepository.processBuffer(MetaDataRepository.java:829)
at org.apache.openjpa.meta.MetaDataRepository.resolveMeta(MetaDataRepository.java:726)
...
의 근본 원인과 63,210
?
모든 향상, 둘 다 내가 그것에 대해 알지 못했기 때문에 그리고 나는 그럴 수 없어. 나는 그들이 모든 것을 자동으로해야한다고 생각한다. :) – Dims