我一直在从事涉及payara服务器的项目。我需要创建/编辑,控制器,dao,服务这三个元素。 Dao是实体bean,而service是实用程序bean。创建dao和service bean之后,我无法运行该项目。发生此错误:
cannot Deploy testtest
deploy is failing=Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'BRCMBuildsheetDao': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.webutility.dao.BRCMBuildsheetDao.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/spring/root-context.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: Repeated column in mapping for entity: com.webutility.dao.BRCMBuildsheetProcess column: brcm_buildsheet_id (should be mapped with insert="false" update="false"). Please see server.log for more details.
编辑: 感谢您指出可能的错误区域。
这是我的BRCMBuildsheetDao.java
包com.webutility.dao;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
@Repository
@Transactional
@Component("BRCMBuildsheetDao")
public class BRCMBuildsheetDao {
@Autowired
private SessionFactory sessionFactory;
public Session session() {
return sessionFactory.getCurrentSession();
}
@SuppressWarnings("unchecked")
public List<BRCMBuildsheet> getAllBuildsheet(){
Criteria crit = session().createCriteria(BRCMBuildsheet.class);
crit.addOrder(Order.desc("id"));
List<BRCMBuildsheet> list = (List<BRCMBuildsheet>) crit.list();
System.out.println(list.size());
return list;
}
@SuppressWarnings("unchecked")
public List<BRCMBuildsheetAssemblyLocations> getAllBuildsheetAssemblyLocation(){
Criteria crit = session().createCriteria(BRCMBuildsheet.class);
crit.addOrder(Order.desc("brcm_buildsheet_assembly_locations_id"));
return (List<BRCMBuildsheetAssemblyLocations>)crit.list();
}
}
This is my BRCMBuildsheetProcess.java
package com.webutility.dao;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Table(name = "brcm_buildsheet", catalog = "b2b")
public class BRCMBuildsheetProcess {
// primary key
@Id
@Column(name = "brcm_buildsheet_id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int brcm_buildsheet_process_id;
// foreign key
// foreign key adjoining
@ManyToOne(fetch = FetchType.EAGER, cascade = { CascadeType.ALL,
CascadeType.PERSIST })
// for table that contains foreign key and stands on many relation end
@JoinColumn(name = "brcm_buildsheet_id")
private BRCMBuildsheet/* change to BRCMBuildsheet */buildsheet; // reference
@Column
private String process_type; // not sure if String or int
@Column
private String system_sites;
@Column
private String frequency_mhz;
@Column
private String io;
@Column
private String vector_memory_mb;
@Column
private String scan_memory_mb;
@Column
private String instruments;
@Column
private String power_supplies;
@Column
private String licenses;
@Column
private String modifier;
@Column
private String test_program_directory;
@Column
private String test_program_rev;
@Column
private String tester_os_rev;
@Column
private String switch_test_option_loadfile;
@Column
private String chipmon_directory;
@Column
private String good_time;
@Column
private String test_temperature_c;
@Column
private String text;
@Column
private String broadcom_legacy_spec_no;
@Column
private String parameter_file;
@Column
private String cime_file;
@Column
private String vector_files;
@Column
private String hardware_profile;
@Column
private String adaptor_board;
@Column
private String change_kit;
@Column
private String contractor;
@Column
private String custom_dut_board;
@Column
private String daughter_board;
@Column
private String mother_board;
@Column
private String power_personality_board;
@Column
private String probe_card;
@Column
private String probe_interface_board;
@Column
private String tower_interface;
@Column
private String prober;
@Column
private String handler;
@Column
private String test_program_flowid;
@Column
private String test_program_auditid;
@Column
private String prr;
// //
public int getBrcm_buildsheet_process_id() {
return brcm_buildsheet_process_id;
}
public void setBrcm_buildsheet_process_id(int rcm_buildsheet_process_id) {
this.brcm_buildsheet_process_id = rcm_buildsheet_process_id;
}
// //
public BRCMBuildsheet getBRCMBuildsheet() {
return this.buildsheet;
}
public void setBRCMBuildsheet(BRCMBuildsheet buildsheet) {
this.buildsheet = buildsheet;
}
// ///
public String getProcess_type() {
return this.process_type;
}
public void setProcess_type(String process_type) {
this.process_type = process_type;
}
// //
public String getSystem_sites() {
return this.system_sites;
}
public void setSystem_sites(String System_sites) {
this.system_sites = System_sites;
}
// /
public String getFrequency_mhz() {
return this.frequency_mhz;
}
public void setFrequency_mhz(String frequency_mhz) {
this.frequency_mhz = frequency_mhz;
}
////
public String getIo(){
return this.io;
}
public void setIo(String io){
this.io = io;
}
////
public String getVector_memory_mb(){
return this.vector_memory_mb;
}
public void setVector_memory_mb(String vector_memory_mb){
this.vector_memory_mb = vector_memory_mb;
}
////
public String getScan_memory_mb(){
return this.scan_memory_mb;
}
public void setScan_memory_mb(String scan_memory_mb){
this.scan_memory_mb = scan_memory_mb;
}
////
public String getInstruments(){
return this.instruments;
}
public void setInstruments(String instruments){
this.instruments = instruments;
}
/////
public String getPower_supplies(){
return this.power_supplies;
}
////
public String getLicenses(){return this.licenses;}
public void setLicenses(String licenses){this.licenses = licenses;}
public String getModifier(){return this.modifier;}
public void setModifier(String modifier){this.modifier = modifier;}
////
public String getTest_program_directory(){return this.test_program_directory;}
public void setTest_program_directory(String test_program_directory){this.test_program_directory = test_program_directory;}
////
public String getTest_program_rev(){return test_program_rev;}
public void set(String test_program_rev){this.test_program_rev = test_program_rev;}
////
public String getTester_os_rev(){ return tester_os_rev;}
public void setTester_os_rev(String tester_os_rev){ tester_os_rev = tester_os_rev;}
/////////
public String getSwitch_test_option_loadfile(){return this.switch_test_option_loadfile;}
public void setSwitch_test_option_loadfile(String switch_test_option_loadfile){this.switch_test_option_loadfile = switch_test_option_loadfile;}
/////
public String getChipmon_directory(){return this.chipmon_directory;}
public void setChipmon_directory(String Chipmon_directory){this.chipmon_directory = chipmon_directory;}
//////
public String getGood_time(){return this.good_time;}
public void setGood_time(String good_time){this.good_time = good_time;}
///////////////
public String getTest_temperature_c(){return this.test_temperature_c;}
public void setTest_temperature_c(){}
///////////////////////////
public String getText(){return this.text;}
public void setText(String text ){this.text = text;}
/////
public String getBroadcom_legacy_spec_no(){return this.broadcom_legacy_spec_no;}
public void setBroadcom_legacy_spec_no(String broadcom_legacy_spec_no){
this.broadcom_legacy_spec_no = broadcom_legacy_spec_no;
}
//////
public String getParameter_file(){return this.parameter_file;}
public void setParameter_file(String parameter_file){this.parameter_file = parameter_file;}
public String getCime_file(){return this.cime_file;}
public void setCime_file(String cime_file){this.cime_file = cime_file;}
////////////
public String getVector_files(){return vector_files;}
public void setVector(String vector_files){this.vector_files = vector_files;}
//////
public String getHardware_profile(){ return this.hardware_profile;}
public void setHardware_profile(String hardware_profile){this.hardware_profile = hardware_profile;}
////
public String getAdaptor_board(){return this.adaptor_board;}
public void setAdaptor_board(String adaptor_board){adaptor_board = adaptor_board;}
////
public String getChange_kit(){return this.change_kit;}
public void setChange_kit(String change_kit){this.change_kit = change_kit;}
/////////
public String getContractor(){return this.contractor;}
public void setContractor(String contractor){this.contractor = contractor;}
//////////////////////
public String getCustom_dut_board(){return this.custom_dut_board;}
public void setCustom_dut_board(String custom_dut_board){this.custom_dut_board = custom_dut_board;}
//////////////////
public String getDaughter_board(){return this.daughter_board;}
public void setDaughter_board(String daughter_board){this.daughter_board = daughter_board;}
//////////////////////////
public String getMother_board(){return this.mother_board;}
public void setMother_board(String mother_board ){ this.mother_board = mother_board;}
///////////
public String getPower_personality_board(){return this.power_personality_board;}
public void setPower_personality_board(String power_personality_board){this.power_personality_board = power_personality_board;}
/////
public String getProbe_card(){return this.probe_card;}
public void setProbe_card(String probe_card){this.probe_card = probe_card;}
public String getProbe_interface_board(){return this.probe_interface_board;}
public void setProbe_interface_board(String probe_interface_board){this.probe_interface_board = probe_interface_board;}
public String getTower_interface(){return this.tower_interface;}
public void setTower_interface(String tower_interface){this.tower_interface = tower_interface;}
public String getHandler(){return this.handler;}
public void setHandler(String handler){this.handler = handler;}
public String getTest_program_flowid(){return this.test_program_flowid;}
public void setTest_program_flowid(String test_program_flowid){ this.test_program_flowid = test_program_flowid;}
public String getTest_program_auditid(){return this.test_program_auditid;}
public void setTest_program_auditid(String test_program_auditid){this.test_program_auditid = test_program_auditid;}
public String getPrr(){return this.prr;}
public void setPrr(String prr){this.prr = prr;}
}
这是我的root-context.xml类
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<!-- Root Context: defines shared resources visible to all other web
components -->
<context:component-scan base-package="com.webutility.dao" />
<context:annotation-config></context:annotation-config>
<tx:annotation-driven transaction-manager="transactionManager" />
<tx:annotation-driven transaction-manager="transactionManager2"
mode="proxy" />
<tx:annotation-driven transaction-manager="transactionManager3"
mode="proxy" />
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="org.postgresql.Driver" />
<property name="url" value="jdbc:postgresql://10.58.8.200:5432/workflow" />
<property name="username" value="poweruser" />
<property name="password" value="pwr764usr" />
</bean>
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
<prop key="show_sql">true</prop>
<prop key="jdbc.batch_size">10000</prop>
</props>
</property>
<property name="packagesToScan">
<list>
<value>com.webutility.dao</value>
</list>
</property>
</bean>
<!-- ******************** -->
<bean id="dataSource2"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="org.postgresql.Driver" />
<property name="url" value="jdbc:postgresql://10.58.8.22:5432/cim" />
<property name="username" value="poweruser" />
<property name="password" value="pwr764usr" />
</bean>
<bean id="transactionManager2"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource2"></property>
</bean>
<bean id="sessionFactory2"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource2" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
<prop key="show_sql">true</prop>
<prop key="jdbc.batch_size">10000</prop>
</props>
</property>
<property name="packagesToScan">
<list>
<value>com.webutility.dao</value>
</list>
</property>
</bean>
<!-- ******************** -->
<bean id="dataSource3"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="org.postgresql.Driver" />
<property name="url" value="jdbc:postgresql://10.58.189.41:5432/rdata" />
<property name="username" value="readonly" />
<property name="password" value="rdnly7543" />
</bean>
<bean id="transactionManager3"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource3"></property>
</bean>
<bean id="sessionFactory3"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource3" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
<prop key="show_sql">true</prop>
<prop key="jdbc.batch_size">10000</prop>
</props>
</property>
<property name="packagesToScan">
<list>
<value>com.webutility.dao</value>
</list>
</property>
</bean>
<!-- ******************** -->
答案 0 :(得分:0)
由于实体类com.webutility.dao.BRCMBuildsheetDao
或com.webutility.dao.BRCMBuildsheetProcess
中的问题,部署失败。
最后一行清楚地表明:
Repeated column in mapping for entity: com.webutility.dao.BRCMBuildsheetProcess column: brcm_buildsheet_id (should be mapped with insert="false" update="false")
请确保映射中没有重复的两列。您可能已经两次映射了同一数据库列
您将能够共享这两个实体类的代码