我在服务器(Tomcat 7 - jdk 1.7)上传了我的Web应用程序(Spring + Hibernate),我收到了这个错误:
Caused by: org.hibernate.HibernateException: Hibernate Dialect must be explicitly set
在我的电脑中,我有相同的配置(Spring,Hibernate,Tomcat 7,jdk 1.7,相同的库等),一切正常。
我查看了互联网,有人说我需要添加hibernate.cfg.xml
,但我从来没有在我的计算机上使用它,一切都运行良好。
这是我在Spring配置文件中的内容:
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="packagesToScan" value="com.jeansedizioni.model"/>
</bean>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${db.driver}" />
<property name="url" value="${db.url}" />
<property name="username" value="${db.user}" />
<property name="password" value="${db.pass}" />
</bean>
<bean id="applicationProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
//here are user, pass etc. for the database
<value>classpath:database.properties</value>
</list>
</property>
</bean>
有人知道我的错误是什么吗?
提前谢谢。
答案 0 :(得分:1)
为struct Singleton {
static let instance : APIManager = APIManager()
}
public class APIManager: NSObject {
public class var sharedInstance: Manager {
return Singleton.instance
}
let manager = APIManager()
override init() {
}
//MARK:====Login====`enter code here`
//MARK: methods
func login(username: String, password: String, completion: @escaping (_ user: user, _ success: Bool) -> (), failed:@escaping (_ error: NSError) -> ()) -> Request {
let urlRequest = "http://fladsrihvyg3ufjld.cvshowcase.com/ios/mobile/signup"// Create a URLRequest and pass to the method
return manager.request(urlRequest)
.validate()
.responseJSON { response in
if let error = response.result.error {
failed(error: error)
print(error)
return;
}
let ok = ((response.result.value as! JSONDictionary)["success"] as? Bool)!
let userJson = JSON((response.result.value as! JSONDictionary)["user"]!)
let token = ((response.result.value as! JSONDictionary)["token"] as? String)!
NSUserDefaults.standardUserDefaults().setValue(token, forKey: UserDefaultKey.Token)
NSUserDefaults.standardUserDefaults().synchronize()
let user = User(json: userJson)
completion(user: user,success: ok)
}
}
}
文件
hibernate.dialect
属性
示例:
database.properties
并将hibernate.dialect=org.hibernate.dialect.SQLServerDialect
添加到您的hibernateProperties
bean声明中,如下所示:
sessionFactory
答案 1 :(得分:1)
在<bean id="sessionFactory">
:
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
</props>
</property>
然后在你的配置文件中(你正在提取用户,传递,url)提及方言,如下所示:
hibernate.dialect=org.hibernate.dialect.OracleDialect
hibernate.show_sql=true
hibernate.hbm2ddl.auto=update