news 2026/7/28 20:13:14

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

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
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 整合完整指南

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/7/28 8:46:04

VisionPro CogIPOneImageTool1 工具超详细解释(含内部功能全解析)

CogIPOneImageTool1 工具一、工具基本定位CogIPOneImageTool1 是康耐视 (Cognex) VisionPro 视觉软件中的单图像基础图像处理工具&#xff0c;专注于对单张输入图像执行像素级的预处理操作&#xff08;如亮度调整、滤波降噪、形态学处理、几何变换等&#xff09;。它是 VisionP…

作者头像 李华
网站建设 2026/7/28 1:28:16

VisionPro CogIDTool 工具超深度详解(技术细节 + 实战配置版)

CogIDTool 工具超深度详解一、工具基本定位&#xff1a;工业条码识读的 “全能型工具”CogIDTool1 是康耐视 (Cognex) VisionPro 中专注于多码制条码 / 二维码识读的专业工具&#xff0c;区别于 VisionPro 中简单的CogBarcodeTool&#xff08;仅支持基础一维码&#xff09;&…

作者头像 李华
网站建设 2026/7/27 10:05:17

让 BI 拥有‘领域大脑’:智能 BI 如何实现 AI 级精准数据查询

随着 AI 广泛应用&#xff0c;企业用户期待商业智能 BI 系统也能实现 AI 式数据查询。业务人员可以在 BI 系统中输入自然语言&#xff0c;比如“我要查今年广东省客户的空调订单金额”&#xff0c;就能得到想要的结果&#xff0c;效率一定会大幅提升&#xff01; 实现 AI 式自…

作者头像 李华
网站建设 2026/7/25 21:13:51

提示工程架构师的战略规划:提示系统生命周期管理

提示工程架构师的战略规划&#xff1a;提示系统生命周期管理——从“零散提示”到“系统能力”的蜕变 一、引入&#xff1a;当提示工程遇到“成长的烦恼” 凌晨2点&#xff0c;某电商公司的算法工程师小李还在电脑前改提示词。上周刚上线的“智能客服提示模板”出了问题——用户…

作者头像 李华
网站建设 2026/7/22 19:28:05

条形码识别与定位:基于FCOS框架的多类型条码检测与识别技术详解

1. 条形码识别与定位&#xff1a;基于FCOS框架的多类型条码检测与识别技术详解 本文共分为六章&#xff0c;各章节内容安排如下&#xff1a; 第一章为绪论。主要介绍研究背景及意义&#xff0c;阐述条形码识别技术的重要性和应用价值&#xff1b;分析国内外研究现状&#xff…

作者头像 李华
网站建设 2026/7/27 21:36:45

AutoGPT能否用于学术文献综述?研究辅助工具测评

AutoGPT能否用于学术文献综述&#xff1f;研究辅助工具测评 在撰写一篇关于“深度学习在医学影像分割中应用”的综述时&#xff0c;你是否曾面对数百篇论文无从下手&#xff1f;手动筛选、逐篇阅读、归纳方法、整理表格——这一系列流程不仅耗时费力&#xff0c;还容易遗漏关键…

作者头像 李华