原来的配置文件

spring.datasource.driver-class-name=com.alibaba.druid.proxy.DruidDriver
spring.datasource.url=jdbc:oracle:thin:@127.0.0.1:1521:orcl
spring.datasource.username=erose
spring.datasource.password=EROSE
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource

mybatis-plus.mapper-locations=classpath:mapper/*_mapper.xml


后来的配置文件

spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
spring.datasource.url=jdbc:oracle:thin:@127.0.0.1:1521:orcl
spring.datasource.username=erose
spring.datasource.password=EROSE
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource

mybatis-plus.mapper-locations=classpath:mapper/*_mapper.xml

DruidDriver替换为oracleDriver后问题得到了解决。
具体原因尚未可知,如有大佬答复,不胜感激。
另附上Oracle配置文件

package com.positioningsystem.configuration;

import com.alibaba.druid.pool.DruidDataSource;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.annotation.MapperScan;
import org.mybatis.spring.mapper.MapperScannerConfigurer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;

import javax.sql.DataSource;
import java.sql.SQLException;

@Configuration
public class DBConfiguration {

    @Value("${spring.datasource.url}")
    private String url;

    @Value("${spring.datasource.username}")
    private String username;

    @Value("${spring.datasource.password}")
    private String passowrd;

    @Value("${spring.datasource.driver-class-name}")
    private String drivername;

    private static final String mapperlocations = "classpath:mapper/*.xml";

    private static final String pageScanse = "com.positioningsystem.dao";

    @Primary
    @Bean(name = "mainDatabase")
    @ConfigurationProperties(prefix = "spring.datasource")
    public DataSource druid(){
        DruidDataSource druidDataSource = new DruidDataSource();
        druidDataSource.setInitialSize(30);
        druidDataSource.setMaxActive(200);
        druidDataSource.setMinIdle(50);
        druidDataSource.setMaxWait(600000);
        try {
            druidDataSource.setFilters("stat,wall");
        }catch (SQLException e){
            e.printStackTrace();
        }
        return druidDataSource;
    }

    @Bean(name = "mainSqlSessionFactory")
    @Primary
    public SqlSessionFactory getSqlSessionFactory(@Qualifier("mainDatabase") DataSource dataSource) throws Exception{
        SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
        sqlSessionFactoryBean.setDataSource(dataSource);
        sqlSessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(mapperlocations));
        sqlSessionFactoryBean.setTypeAliasesPackage(pageScanse);
        return sqlSessionFactoryBean.getObject();
    }

}

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐