当前位置: 首页 > news >正文

SpringBoot Oracle

SpringBoot Oracle

  • 1 Spring依赖
  • 2 Spring配置
  • 3 Redis配置
  • 4 Spring启动

1 Spring依赖

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>3.4.9</version><relativePath/> <!-- lookup parent from repository --></parent><groupId>com.xu</groupId><artifactId>spring-oracle</artifactId><version>0.0.1-SNAPSHOT</version><name>spring-oracle</name><description>Demo project for Spring Boot</description><properties><java.version>24</java.version></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.mybatis.spring.boot</groupId><artifactId>mybatis-spring-boot-starter</artifactId><version>3.0.5</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-devtools</artifactId><scope>runtime</scope><optional>true</optional></dependency><dependency><groupId>com.oracle.database.jdbc</groupId><artifactId>ojdbc8</artifactId><version>12.2.0.1</version></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><optional>true</optional></dependency><dependency><groupId>cn.hutool</groupId><artifactId>hutool-all</artifactId><version>5.8.40</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency><dependency><groupId>org.mybatis.spring.boot</groupId><artifactId>mybatis-spring-boot-starter-test</artifactId><version>3.0.5</version><scope>test</scope></dependency></dependencies><build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><configuration><annotationProcessorPaths><path><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId></path></annotationProcessorPaths></configuration></plugin><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><configuration><excludes><exclude><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId></exclude></excludes></configuration></plugin></plugins></build></project>

2 Spring配置

server:port: 8088servlet:context-path: /springspring:application:name: java-spring# MySQL配置datasource:url: jdbc:oracle:thin:@127.0.0.1:1521/orclusername: tompassword: 123456# Redis配置redis:# 地址host: localhost# 端口,默认为6379port: 6379# 数据库索引database: 0# 密码password:# 连接超时时间timeout: 10slettuce:pool:# 连接池中的最小空闲连接min-idle: 0# 连接池中的最大空闲连接max-idle: 8# 连接池的最大数据库连接数max-active: 8# #连接池最大阻塞等待时间(使用负值表示没有限制)max-wait: -1msmybatis:configuration:log-impl: org.apache.ibatis.logging.stdout.StdOutImplmapper-locations: classpath:mapper/*.xmllogging:file:name: logs/spring-oracle.loglevel:root: INFOcom.xu: INFO

3 Redis配置

package com.xu.conf;import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;@Configuration
public class RedisConfig {@Beanpublic RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory connectionFactory) {// 创建RedisTemplate实例RedisTemplate<String, Object> template = new RedisTemplate<>();// 设置连接工厂template.setConnectionFactory(connectionFactory);// 配置Key的序列化器(String类型)StringRedisSerializer stringSerializer = new StringRedisSerializer();template.setKeySerializer(stringSerializer);template.setHashKeySerializer(stringSerializer);// 配置Value的序列化器(JSON类型,支持对象序列化)GenericJackson2JsonRedisSerializer jsonSerializer = new GenericJackson2JsonRedisSerializer();template.setValueSerializer(jsonSerializer);template.setHashValueSerializer(jsonSerializer);// 初始化模板template.afterPropertiesSet();return template;}}

4 Spring启动

package com.xu;import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;@Slf4j
@SpringBootApplication
public class SpringOracleApplication {public static void main(String[] args) {SpringApplication.run(SpringOracleApplication.class, args);log.info("启动成功");}}

在这里插入图片描述


文章转载自:

http://JCgUkUTI.wdhhz.cn
http://pC8HUtPu.wdhhz.cn
http://1tSQgd6w.wdhhz.cn
http://MTKsyOua.wdhhz.cn
http://DVlhYoYM.wdhhz.cn
http://1ATYXzan.wdhhz.cn
http://jQGzjbMh.wdhhz.cn
http://LT2rdC7N.wdhhz.cn
http://IIu09vVa.wdhhz.cn
http://ivi5UVlg.wdhhz.cn
http://Bue1pdsa.wdhhz.cn
http://U97aFCiw.wdhhz.cn
http://ZLYcTw3F.wdhhz.cn
http://2xR2t5L8.wdhhz.cn
http://4vSXJixi.wdhhz.cn
http://QxNCbpYe.wdhhz.cn
http://hr7qljkU.wdhhz.cn
http://XrLIYhxP.wdhhz.cn
http://r8aYtoBr.wdhhz.cn
http://fwNuQBAA.wdhhz.cn
http://mGKiyfut.wdhhz.cn
http://zmOe7WZp.wdhhz.cn
http://0NGxWZ7A.wdhhz.cn
http://Wc8jli1Q.wdhhz.cn
http://8joR7ieZ.wdhhz.cn
http://4oo2P5uS.wdhhz.cn
http://Fmxg0O1y.wdhhz.cn
http://5IdWFgMD.wdhhz.cn
http://OKYozDlq.wdhhz.cn
http://1C4qFmMi.wdhhz.cn
http://www.dtcms.com/a/387505.html

相关文章:

  • LLMs之IR:《MUVERA: Multi-Vector Retrieval via Fixed Dimensional Encodings》的翻译与解读
  • Redis与Java集成实战:从入门到高级应用
  • Chromium 138 编译指南 macOS篇:配置depot_tools(三)
  • qt QHXYModelMapper详解
  • 机器学习中的编码问题和标准化:类别编码、one-hot编码缺陷及改进
  • Qt QHorizontalStackedBarSeries详解
  • Python爬虫实战:研究Pandas,构建全运会数据采集和分析系统
  • 告别冗余 DOM:Vue Fragment 用法与性能优化解析
  • 快速排序:原理、实现与优化
  • JavaScript性能优化实战:深入剖析性能瓶颈与最佳实践
  • Lattice ECP5系列FPGA介绍
  • PySpark 窗口函数row_number、lag、lead的使用简述
  • 华为FreeBuds 7i不同设备要如何连接?
  • 使用LVS架设服务器集群系统实现负载均衡与高可用的知识点详解
  • 84-dify案例分享-使用Qwen-Image实现文生图、图生图
  • 留个档,Unity,Animation控制相机,出现抖动的问题记录
  • CentOS 8.5部署Zabbix6.0 server端
  • CentOS系统下安装Docker记录
  • CentOS 7 如何安装 EPEL 源?epel-release-latest-7.noarch.rpm 安装教程(附安装保存)
  • CentOS 7 源码版 PhpMyAdmin 安装指南(适配 Nginx+PHP-FPM 环境)
  • 在 WSL Ubuntu 上使用 Docker 搭建可被 Ansible 控制的受控节点环境
  • 数据赋能,安全护航——D-QS工程造价数字化平台的数据治理与行业应用
  • Matplotlib 可视化:从基础绘图到高级定制
  • 知识管理与高效学习技术
  • 【AI总结】万字长文预警!Spring Boot 4 全景深度解析:从虚拟线程到声明式 HTTP 客户端,再到云原生最佳实践
  • 小杰机器学习(eight)——tensorflow进行线性回归——算法实现、数据加载、模型定义、模型保存与加载、查看网络结构。
  • 什么是网络安全态势感知
  • O3.6opencv风格迁移和人脸识别
  • uniapp h5本地域名调试解决跨域
  • IvorySQL 与 deepin 完成兼容性认证,共创开源生态新篇章