将hibernate与CAS集成时的org.hibernate.MappingException

时间:2011-11-16 20:27:26

标签: hibernate spring jpa cas

我的大学正在设立CAS。目前,我正致力于将hibernate与CAS集成,以便CAS可以连接到数据库,并且一直遵循本指南: https://wiki.jasig.org/display/CASUM/Configuring

完整堆栈跟踪:

SEVERE: Exception starting filter springSecurityFilterChain
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'servicesManager' defined in ServletContext resource [/WEB-INF/spring-configuration/applicationContext.xml]: Cannot resolve reference to bean 'serviceRegistryDao' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serviceRegistryDao' defined in ServletContext resource [/WEB-INF/deployerConfigContext.xml]: Cannot resolve reference to bean 'entityManagerFactory' while setting bean property 'entityManagerFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/deployerConfigContext.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: CasPersistence] Unable to build EntityManagerFactory
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:616)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:148)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1003)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:907)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.jasig.cas.web.init.SafeContextLoaderListener.contextInitialized_aroundBody0(SafeContextLoaderListener.java:62)
at org.jasig.cas.web.init.SafeContextLoaderListener.contextInitialized_aroundBody1$advice(SafeContextLoaderListener.java:44)
at org.jasig.cas.web.init.SafeContextLoaderListener.contextInitialized(SafeContextLoaderListener.java:1)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serviceRegistryDao' defined in ServletContext resource [/WEB-INF/deployerConfigContext.xml]: Cannot resolve reference to bean 'entityManagerFactory' while setting bean property 'entityManagerFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/deployerConfigContext.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: CasPersistence] Unable to build EntityManagerFactory
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
... 28 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/deployerConfigContext.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: CasPersistence] Unable to build EntityManagerFactory
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
... 38 more
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: CasPersistence] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:890)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:308)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
... 45 more
Caused by: org.hibernate.MappingException: Could not determine type for: java.util.List, at table: RegisteredServiceImpl, for columns: [org.hibernate.mapping.Column(a_name)]
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:304)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:288)
at org.hibernate.mapping.Property.isValid(Property.java:216)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:467)
at org.hibernate.mapping.RootClass.validate(RootClass.java:268)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1287)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1718)
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:76)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:905)
... 51 more

我的serviceRegistryDao和dataSource bean:

<bean id="serviceRegistryDao" class="org.jasig.cas.services.JpaServiceRegistryDaoImpl"
p:entityManagerFactory-ref="entityManagerFactory" />
<!-- This is the EntityManagerFactory configuration for Hibernate -->
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="dataSource" ref="dataSource"/>
    <property name="jpaVendorAdapter">
        <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
            <property name="generateDdl" value="true"/>
            <property name="showSql" value="true" />
        </bean>
    </property>
    <property name="jpaProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
            <prop key="hibernate.hbm2ddl.auto">update</prop>
        </props>
    </property>
</bean>

<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>

<tx:annotation-driven transaction-manager="transactionManager"/>


<bean
    id="dataSource"
    class="org.apache.commons.dbcp.BasicDataSource"
    p:driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
    p:url="jdbc:sqlserver://xx.xx.xx.xx:xxxx;databaseName=XXX"
    p:password="XXXXX"
    p:username="XXXXX" />

我还将我的persistence.xml文件放在这里,但我从默认情况下都没有改变它:

<persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
    version="2.0">

<persistence-unit name="CasPersistence" transaction-type="RESOURCE_LOCAL">
    <class>org.jasig.cas.services.RegisteredServiceImpl</class>
    <class>org.jasig.cas.ticket.TicketGrantingTicketImpl</class>
    <class>org.jasig.cas.ticket.ServiceTicketImpl</class>
</persistence-unit>
</persistence>

RegisteredServiceImpl.java(来自cas-server-core-3.4.10.jar,可以在这里探讨:http://www.jarvana.com/jarvana/inspect/org/jasig/cas/cas-server-core/3.4.10/cas-server-core-3.4.10-sources.jar

/*
 * Copyright 2007 The JA-SIG Collaborative. All rights reserved. See license
 * distributed with this file and available online at
 * http://www.uportal.org/license.html
 */
package org.jasig.cas.services;

import java.sql.Array;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinTable;

import javax.persistence.GenerationType;

import org.apache.commons.lang.builder.ToStringBuilder;Class search for 'org.apache.commons.lang.builder.ToStringBuilder'
import org.apache.commons.lang.builder.ToStringStyle;Class search for 'org.apache.commons.lang.builder.ToStringStyle'
import org.hibernate.annotations.CollectionOfElements;Class search for 'org.hibernate.annotations.CollectionOfElements'
import org.hibernate.annotations.IndexColumn;Class search for 'org.hibernate.annotations.IndexColumn'
import org.jasig.cas.authentication.principal.Service;Class search for 'org.jasig.cas.authentication.principal.Service'
import org.springframework.util.AntPathMatcher;Class search for 'org.springframework.util.AntPathMatcher'
import org.springframework.util.Assert;Class search for 'org.springframework.util.Assert'
import org.springframework.util.PathMatcher;Class search for 'org.springframework.util.PathMatcher'

/**
 * Mutable implementation of a RegisteredService.
 * 
 * @author Scott Battaglia
 * @version $Revision: 22918 $ $Date: 2011-02-06 23:02:50 -0500 (Sun, 06 Feb 2011) $
 * @since 3.1
 */
@Entity
public class RegisteredServiceImpl
    implements RegisteredService, Comparable<RegisteredService> {

/** Unique Id for serialization. */
private static final long serialVersionUID = -5136788302682868276L;

private static final PathMatcher PATH_MATCHER = new AntPathMatcher();

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id = -1;


@CollectionOfElements(targetElement = String.class, fetch = FetchType.EAGER)
@JoinTable(name = "rs_attributes")
@Column(name = "a_name", nullable = false)
@IndexColumn(name = "a_id")
private List<String> allowedAttributes = new ArrayList<String>();

private String description;

private String serviceId;

private String name;

private String theme;

private boolean allowedToProxy = true;

private boolean enabled = true;

private boolean ssoEnabled = true;

private boolean anonymousAccess = false;

private boolean ignoreAttributes = false;

@Column(name = "evaluation_order", nullable = false)
private int evaluationOrder;

public boolean isAnonymousAccess() {
    return this.anonymousAccess;
}

public void setAnonymousAccess(final boolean anonymousAccess) {
    this.anonymousAccess = anonymousAccess;
}

public List<String> getAllowedAttributes() {
    return this.allowedAttributes;
}

public long getId() {
    return this.id;
}

public String getDescription() {
    return this.description;
}

public String getServiceId() {
    return this.serviceId;
}

public String getName() {
    return this.name;
}

public String getTheme() {
    return this.theme;
}

public boolean isAllowedToProxy() {
    return this.allowedToProxy;
}

public boolean isEnabled() {
    return this.enabled;
}

public boolean isSsoEnabled() {
    return this.ssoEnabled;
}

public boolean matches(final Service service) {
    return service != null && PATH_MATCHER.match(this.serviceId.toLowerCase(), service.getId().toLowerCase());
}

@Override
public boolean equals(Object o) {
    if (this == o) return true;
    if (!(o instanceof RegisteredServiceImpl)) return false;

    RegisteredServiceImpl that = (RegisteredServiceImpl) o;

    if (allowedToProxy != that.allowedToProxy) return false;
    if (anonymousAccess != that.anonymousAccess) return false;
    if (enabled != that.enabled) return false;
    if (evaluationOrder != that.evaluationOrder) return false;
    if (ignoreAttributes != that.ignoreAttributes) return false;
    if (ssoEnabled != that.ssoEnabled) return false;
    if (allowedAttributes != null ? !allowedAttributes.equals(that.allowedAttributes) : that.allowedAttributes != null)
        return false;
    if (description != null ? !description.equals(that.description) : that.description != null) return false;
    if (name != null ? !name.equals(that.name) : that.name != null) return false;
    if (serviceId != null ? !serviceId.equals(that.serviceId) : that.serviceId != null) return false;
    if (theme != null ? !theme.equals(that.theme) : that.theme != null) return false;

    return true;
}

@Override
public int hashCode() {
    int result = allowedAttributes != null ? allowedAttributes.hashCode() : 0;
    result = 31 * result + (description != null ? description.hashCode() : 0);
    result = 31 * result + (serviceId != null ? serviceId.hashCode() : 0);
    result = 31 * result + (name != null ? name.hashCode() : 0);
    result = 31 * result + (theme != null ? theme.hashCode() : 0);
    result = 31 * result + (allowedToProxy ? 1 : 0);
    result = 31 * result + (enabled ? 1 : 0);
    result = 31 * result + (ssoEnabled ? 1 : 0);
    result = 31 * result + (anonymousAccess ? 1 : 0);
    result = 31 * result + (ignoreAttributes ? 1 : 0);
    result = 31 * result + evaluationOrder;
    return result;
}

public void setAllowedAttributes(final List<String> allowedAttributes) {
    if (allowedAttributes == null) {
        this.allowedAttributes = new ArrayList<String>();
    } else {
        this.allowedAttributes = allowedAttributes;
    }
}

public void setAllowedToProxy(final boolean allowedToProxy) {
    this.allowedToProxy = allowedToProxy;
}

public void setDescription(final String description) {
    this.description = description;
}

public void setEnabled(final boolean enabled) {
    this.enabled = enabled;
}

public void setServiceId(final String id) {
    this.serviceId = id;
}

public void setId(final long id) {
    this.id = id;
}

public void setName(final String name) {
    this.name = name;
}

public void setSsoEnabled(final boolean ssoEnabled) {
    this.ssoEnabled = ssoEnabled;
}

public void setTheme(final String theme) {
    this.theme = theme;
}

public boolean isIgnoreAttributes() {
    return this.ignoreAttributes;
}

public void setIgnoreAttributes(final boolean ignoreAttributes) {
    this.ignoreAttributes = ignoreAttributes;
}

public void setEvaluationOrder(final int evaluationOrder) {
    this.evaluationOrder = evaluationOrder;
}

public int getEvaluationOrder() {
    return this.evaluationOrder;
}

public Object clone() throws CloneNotSupportedException {
    final RegisteredServiceImpl registeredServiceImpl = new RegisteredServiceImpl();

    registeredServiceImpl.setAllowedAttributes(this.allowedAttributes);
    registeredServiceImpl.setAllowedToProxy(this.allowedToProxy);
    registeredServiceImpl.setDescription(this.description);
    registeredServiceImpl.setEnabled(this.enabled);
    registeredServiceImpl.setId(this.id);
    registeredServiceImpl.setName(this.name);
    registeredServiceImpl.setServiceId(this.serviceId);
    registeredServiceImpl.setSsoEnabled(this.ssoEnabled);
    registeredServiceImpl.setTheme(this.theme);
    registeredServiceImpl.setAnonymousAccess(this.anonymousAccess);
    registeredServiceImpl.setIgnoreAttributes(this.ignoreAttributes);
    registeredServiceImpl.setEvaluationOrder(this.evaluationOrder);

    return registeredServiceImpl;
}


public int compareTo(final RegisteredService other) {
    final int result = this.evaluationOrder - other.getEvaluationOrder();
    if (result == 0) {
        return (int)(this.id - other.getId());
    }
    return result;
}

@Override
public String toString() {
    final ToStringBuilder toStringBuilder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE);
    toStringBuilder.append("id", this.id);
    toStringBuilder.append("name", this.name);
    toStringBuilder.append("description", this.description);
    toStringBuilder.append("serviceId", this.serviceId);
    toStringBuilder.append("attributes", this.allowedAttributes.toArray());

    return toStringBuilder.toString();
}
}

非常感谢任何帮助/建议。如果有任何其他信息我应该发布,请告诉我。

2 个答案:

答案 0 :(得分:0)

我最近将CAS更新到版本3.4.11,但这不应该改变我的解决方案的适用性。

以下显示了deployerConfigContext.xml

中的数据源定义
<bean
    id="dataSource"
    class="com.mchange.v2.c3p0.ComboPooledDataSource"
    p:driverClass="${database.driverClass}"
    p:jdbcUrl="${database.url}"
    p:user="${database.user}"
    p:password="${database.password}"
    p:initialPoolSize="${database.pool.minSize}"
    p:minPoolSize="${database.pool.minSize}"
    p:maxPoolSize="${database.pool.maxSize}"
    p:maxIdleTimeExcessConnections="${database.pool.maxIdleTime}"
    p:checkoutTimeout="${database.pool.maxWait}"
    p:acquireIncrement="${database.pool.acquireIncrement}"
    p:acquireRetryAttempts="${database.pool.acquireRetryAttempts}"
    p:acquireRetryDelay="${database.pool.acquireRetryDelay}"
    p:idleConnectionTestPeriod="${database.pool.idleConnectionTestPeriod}"
    p:preferredTestQuery="${database.pool.connectionHealthQuery}"
    />

以及cas.properties中的相应字段

# == Basic database connection pool configuration ==
database.dialect=org.hibernate.dialect.SQLServerDialect
database.driverClass=net.sourceforge.jtds.jdbc.Driver
database.url=jdbc:jtds:sqlserver://server.uni.it:52112/CAS;instance=zzzzz;domain=UNI
database.user=xxxxx
database.password=yyyyy
database.pool.minSize=6
database.pool.maxSize=18
# Maximum amount of time to wait in ms for a connection to become
# available when the pool is exhausted
database.pool.maxWait=10000
# Amount of time in seconds after which idle connections
# in excess of minimum size are pruned.
database.pool.maxIdleTime=120
# Number of connections to obtain on pool exhaustion condition.
# The maximum pool size is always respected when acquiring
# new connections.
database.pool.acquireIncrement=6
# == Connection testing settings ==
# Period in s at which a health query will be issued on idle
# connections to determine connection liveliness.
database.pool.idleConnectionTestPeriod=30
# Query executed periodically to test health
database.pool.connectionHealthQuery=select 1
# == Database recovery settings ==
# Number of times to retry acquiring a _new_ connection
# when an error is encountered during acquisition.
database.pool.acquireRetryAttempts=5
# Amount of time in ms to wait between successive aquire retry attempts.
database.pool.acquireRetryDelay=2000

我的persistence.xml(如果实施锁定策略,则只需要Lock)

<persistence xmlns="http://java.sun.com/xml/ns/persistence"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
        version="2.0">

    <persistence-unit name="CasPersistence" transaction-type="RESOURCE_LOCAL">
        <class>org.jasig.cas.services.RegisteredServiceImpl</class>
        <class>org.jasig.cas.ticket.TicketGrantingTicketImpl</class>
        <class>org.jasig.cas.ticket.ServiceTicketImpl</class>
        <class>org.jasig.cas.ticket.registry.support.JpaLockingStrategy$Lock</class>
    </persistence-unit>
</persistence>

最后但并非最不重要的是相应的pom.xml条目

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-entitymanager</artifactId>
    <version>${hibernate.version}</version>
    <scope>runtime</scope>
</dependency>
    <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>${hibernate.version}</version>
    <scope>runtime</scope>
</dependency>
<dependency>
    <groupId>c3p0</groupId>
    <artifactId>c3p0</artifactId>
    <version>${c3p0.version}</version>
</dependency>
<dependency>
    <groupId>net.sourceforge.jtds</groupId>
    <artifactId>jtds</artifactId>
    <version>${sqlserver-connector.version}</version>
</dependency>

也许它通过使用这个SQL-Server驱动程序来解决

答案 1 :(得分:0)

我遇到了类似的问题。屏幕上出现此错误有两个原因。

  1. 您的.jar文件可能彼此不兼容。
  2. 类路径中添加的.jar文件可能与jdk的版本不兼容。
  3. 可能存在添加相同jar但版本不同的情况。
  4. 在上面提到的3个原因之外,看起来你有与jar的jdk兼容性。