news 2026/6/24 0:39:30

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/6/22 22:56:24

安装包太大难管理?vLLM镜像轻量化部署解决方案

vLLM镜像轻量化部署&#xff1a;破解大模型推理的性能与运维困局 在生成式AI浪潮席卷各行各业的今天&#xff0c;企业对大语言模型&#xff08;LLM&#xff09;的依赖正从“能用”迈向“好用、快用、低成本用”。然而&#xff0c;当我们将 LLaMA、Qwen 或 ChatGLM 这类主流大模…

作者头像 李华
网站建设 2026/6/20 23:31:36

AutoGPT镜像定制化服务开放:满足企业特殊需求

AutoGPT镜像定制化服务开放&#xff1a;满足企业特殊需求 在智能办公的浪潮中&#xff0c;一个现实问题正困扰着越来越多的企业&#xff1a;尽管AI技术日新月异&#xff0c;但真正能“独当一面”的自动化工具却依然稀缺。员工每天仍需手动整合数据、撰写报告、跨系统查询信息—…

作者头像 李华
网站建设 2026/6/17 15:43:01

利用PHP一句话木马实现远程控制

1.实验背景在网络攻防中&#xff0c;“远程控制”是攻击者获取权限后的重要阶段WebShell&#xff08;网页后门&#xff09;实现这一目标的常见手段之一。本次实验旨在通过最基础的PHP代码&#xff0c;理解“一句话木马”的工作原理&#xff0c;并演示如何通过Web请求在目标服务…

作者头像 李华
网站建设 2026/6/23 10:08:39

移动应用测试中的Monkey随机测试:原理、实践与优化策略‌

在移动互联网高速发展的今天&#xff0c;移动端应用已成为人们日常生活和商业活动的核心载体。然而&#xff0c;随着应用复杂度的提升&#xff0c;传统的测试方法往往难以覆盖所有边界场景&#xff0c;尤其是用户交互的随机性和不可预测性。Monkey随机测试作为一种高效的自动化…

作者头像 李华
网站建设 2026/6/24 5:55:06

白帽子黑客挣钱攻略,别说兄弟发财不带你!

白帽子黑客挣钱攻略&#xff0c;别说兄弟发财不带你&#xff01; 对于白帽子黑客&#xff0c;很多人的理解应该只停留在概念表层&#xff0c;今天成哥在这里整理了一些具体到工作和挣钱路径的内容&#xff0c;供大家参考哦。 1.挖掘漏洞挣奖金 通用程序漏洞&#xff0c;顾名思…

作者头像 李华
网站建设 2026/6/23 18:28:43

当金融大脑植入社交躯体:下一代DApp网站如何成为自进化的数字王国

当金融大脑植入社交躯体&#xff1a;下一代DApp网站如何成为自进化的数字王国 深夜&#xff0c;你开发的DApp网站日活持续下滑&#xff0c;智能合约锁仓量停滞不前。后台数据显示&#xff0c;80%的用户在连接钱包后的第三屏悄然离开——这不是产品问题&#xff0c;这是架构级困…

作者头像 李华