0
私は春と冬眠の初心者です。私はダミーアプリケーションを作成してこの例外を取得しています。私はこれをたくさん検索しましたが、これに対する解決策は見つかりませんでした。 PLZコンテキストの初期化に失敗しました。ファイルが見つかりません[javax/persistence/Entity.class]が存在しないためオープンできません。
SEVERE: Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to load bean class: com.sm.entity.User; nested exception is java.io.FileNotFoundException: class path resource [javax/persistence/Entity.class] cannot be opened because it does not exist
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:267)
そして、ここでは私のcontextApplication.xmlファイル
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<context:annotation-config />
<context:component-scan base-package="com.sm.controller, com.sm.dao, com.sm.entity, com.sm.model, com.sm.service"/>
<context:property-placeholder location="file:D:\workspace\SM\src\main\resources\System.property"/>
<!--<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basenames">
<list>
<!–<value>file:D:\admins\new\m-POS_Merchant_Portal\opt\estel\mpos\mPOSMerchantPortal\conf\messages</value>–>
<!–<value>file:D:\admins\new\m-POS_Merchant_Portal\opt\estel\mpos\mPOSMerchantPortal\conf\system</value>–>
<value>file:D:\Estel\m-POS_Merchant_Portal\opt\estel\mpos\mPOSMerchantPortal\conf\messages</value>
<value>file:D:\Estel\m-POS_Merchant_Portal\opt\estel\mpos\mPOSMerchantPortal\conf\system</value>
</list>
</property>
<property name="cacheSeconds" value="1"/>
<property name="useCodeAsDefaultMessage" value="true"/>
<property name="defaultEncoding" value="UTF-8" />
</bean>-->
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basenames">
<list>
<value>
file:D:\workspace\SM\src\main\resources\System.property
</value>
</list>
</property>
<property name="cacheSeconds" value="1"/>
<property name="useCodeAsDefaultMessage" value="true"/>
<property name="defaultEncoding" value="UTF-8" />
</bean>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" >
<property name="driverClassName" value="${jdbc.driverClassName}"/>
<property name="url" value="${jdbc.databaseurl}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" ref="${jdbc.password}"/>
</bean>
<!--<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">-->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="packagesToScan" value="com.sm.entity" />
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
<property name="configurationClass">
<value>org.hibernate.cfg.AnnotationConfiguration</value>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${jdbc.dialect}</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
</bean>
<!--<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>-->
</beans>
そして、ここで私を助けることは、私の実体ファイルである
package com.sm.entity;
import org.springframework.stereotype.Component;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Table;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.GenerationType;
import java.io.Serializable;
/**
* Created by dinesh on 9/5/16.
*/
@Component
@Entity
@Table(name = "user")
public class User implements Serializable{
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="user_id")
public Long userId;
@Column(name="name")
public String name;
@Column(name="password")
public String password;
@Column(name="email")
public String email;
@Column(name="phone")
public String phone;
@Column(name="mobile")
public String mobile;
@Column(name="type")
public String type;
@Column(name="status")
public String status;
@Column(name="country")
public String country;
@Column(name="state")
public String state;
@Column(name="city")
public String city;
@Column(name="address")
public String address;
public User(){}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
}
ここではhibernate.cfg.xmlが
<hibernate-configuration>
<session-factory>
<mapping class="com.sm.entity.User"/>
</session-factory>
</hibernate-configuration>
ファイルであります
すでに私はそれを述べています。私は今私の質問を更新しました –