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

SpringBoot4.0合 Scala/Java 混编?我踩过的坑,请你绕行

SpringBoot4.0合 Scala/Java 混编?我踩过的坑,请你绕行

本节说明一下Scala和Java混合开发时,本地运行没问题,只要上线部署打成Jar包就会找不到启动类,启动时就会报错

1. 需要配置两个东西

1. Scala的依赖 2. Scala的打包插件

2. Scala打包部署

<dependency><groupId>org.scala-lang</groupId><artifactId>scala-library</artifactId><version>2.13.6</version><!-- 使用适合你项目的版本 --></dependency>

3. Scala打包插件

<!-- Scala Compiler --><plugin><groupId>net.alchim31.maven</groupId><artifactId>scala-maven-plugin</artifactId><version>4.4.1</version><executions><execution><goals><goal>compile</goal><goal>testCompile</goal></goals></execution></executions><configuration><scalaVersion>2.13.16</scalaVersion></configuration></plugin>

4. Scala打包效果

5. 完整Pom依赖

<?xml version="1.0" encoding="UTF-8"?><projectxmlns="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 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.cloud.xx</groupId><artifactId>xx-cloud</artifactId><version>1.0-SNAPSHOT</version><properties><maven.compiler.source>17</maven.compiler.source><maven.compiler.target>17</maven.compiler.target><mybatis-plus.version>3.4.3</mybatis-plus.version><mysql.connector.version>8.0.16</mysql.connector.version><hutool-all.version>5.8.18</hutool-all.version></properties><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>4.0.1-SNAPSHOT</version></parent><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><!--knife4j 在线接口文档--><dependency><groupId>com.github.xiaoymin</groupId><artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId><version>4.5.0</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter</artifactId></dependency><dependency><groupId>javax.servlet</groupId><artifactId>javax.servlet-api</artifactId><version>3.1.0</version><scope>provided</scope></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-validation</artifactId></dependency><dependency><groupId>com.dtflys.forest</groupId><artifactId>forest-spring-boot3-starter</artifactId><version>1.5.35</version></dependency><dependency><groupId>cn.hutool</groupId><artifactId>hutool-all</artifactId><version>${hutool-all.version}</version></dependency><dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-spring-boot4-starter</artifactId><version>3.5.14</version></dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>${mysql.connector.version}</version></dependency><dependency><groupId>com.alibaba</groupId><artifactId>fastjson</artifactId><version>1.2.79</version></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.18.22</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency><!-- 或者使用PostgreSQL兼容驱动 --><!-- https://mvnrepository.com/artifact/org.postgresql/postgresql --><dependency><groupId>org.postgresql</groupId><artifactId>postgresql</artifactId><version>42.7.8</version></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><scope>provided</scope></dependency><dependency><groupId>junit</groupId><artifactId>junit</artifactId><scope>test</scope></dependency><dependency><groupId>org.scala-lang</groupId><artifactId>scala-library</artifactId><version>2.13.6</version><!-- 使用适合你项目的版本 --></dependency></dependencies><build><finalName>xx-cloud</finalName><plugins><!-- Scala Compiler --><plugin><groupId>net.alchim31.maven</groupId><artifactId>scala-maven-plugin</artifactId><version>4.4.1</version><executions><execution><goals><goal>compile</goal><goal>testCompile</goal></goals></execution></executions><configuration><scalaVersion>2.13.16</scalaVersion></configuration></plugin><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><configuration><mainClass>com.cloud.xx.ApplicationBoot</mainClass><includeSystemScope>true</includeSystemScope></configuration></plugin></plugins></build><repositories><repository><id>spring-snapshots</id><url>https://repo.spring.io/snapshot</url><snapshots><enabled>true</enabled></snapshots></repository><repository><id>spring-milestones</id><url>https://repo.spring.io/milestone</url></repository></repositories><pluginRepositories><pluginRepository><id>spring-snapshots</id><url>https://repo.spring.io/snapshot</url></pluginRepository><pluginRepository><id>spring-milestones</id><url>https://repo.spring.io/milestone</url></pluginRepository></pluginRepositories></project>

6. 往/期/回/顾

REVIEW

2026年SpringCloudAlibaba全家桶+三个全栈零基础实战项目

杀疯了Spring Boot 4.0 最新特性整合 MyBatis-Plus 完整教程

《深夜救急!一次微信关单事故,让我重构了整个SpringCloud Alibaba支付架构》

Spring Boot 4.0 与 Mybatis Plus 整合完整指南

http://www.cnnetsun.cn/news/65939.html

相关文章:

  • VisionPro CogIPOneImageTool1 工具超详细解释(含内部功能全解析)
  • VisionPro CogIDTool 工具超深度详解(技术细节 + 实战配置版)
  • 让 BI 拥有‘领域大脑’:智能 BI 如何实现 AI 级精准数据查询
  • 提示工程架构师的战略规划:提示系统生命周期管理
  • 条形码识别与定位:基于FCOS框架的多类型条码检测与识别技术详解
  • AutoGPT能否用于学术文献综述?研究辅助工具测评
  • 如何用AutoGPT实现任务全自动执行?深度解析开源大模型能力
  • Mapbox GL JS 核心表达式:`in` 包含判断完全教程
  • Web3双核引擎:当AI量化金融大脑,遇见DAO社交生态灵魂
  • CEX开发困局:当达普韦伯为交易所注入“数字灵魂”
  • AutoGPT镜像集成指南:如何嵌入现有业务系统?
  • AutoGPT项目活跃度分析:GitHub星标增长趋势
  • AutoGPT能否生成短视频脚本?内容创作新方式
  • 超越ChatGPT!教你开发能自主完成复杂任务的AI智能体,代码开源
  • 震惊!AI Agent智商税?Google最新研究:盲目堆叠智能体可能导致性能暴跌70%
  • AI Agent“杀疯了“!大模型时代,你的编程技能该“内卷“还是“躺平“?
  • 【AI神器】Claude Code四大神器全解析!小白程序员也能秒变效率王者,Command/Skill/Agent/MCP一次搞懂!
  • AutoGPT能否接入企业微信?组织内协作场景落地
  • 震惊!原来AI编程开发这么简单:LLM、Agent与Workflow三兄弟协同工作原理大揭秘,小白也能秒变AI达人!
  • 图灵奖大佬怒怼大模型:LLM不是通向AGI的路径!下一波AI革命竟是洗碗倒水?程序员必看!
  • 从“十五五”规划建议看数字孪生重点发展方向
  • Qwen3-32B中文理解能力为何如此出色?内部机制揭秘
  • BPAdaboost模型:以BP神经网络为‘弱‘分类器的强分类器构建方法
  • 16、科学计算实用指南:从矩阵运算到生物信息学
  • LobeChat文件上传功能怎么用?处理PDF、Word超简单
  • BTC波动加剧之际,投资者如何选择可靠的数字资产观察平台?
  • 基于springboot的水果购物商城管理系统的设计与实现_5n1fg985
  • 计算机毕业设计springboot家庭理财系统 基于 SpringBoot 的个人家庭资产管理系统 SpringBoot+Vue 的智能化家庭财务分析与规划平台
  • 论文写作新范式:基于9款AI工具的实战评测,开题报告与草稿高效产出
  • 兼容性测试云平台使用方法