benjaminluochun 2026-04-03 11:00 采纳率: 0%
浏览 8

koupleless框架模块部署问题

我搭建了一个koupleless的简单示例框架,一个基座和一个动态模块,部署后模块显示部署成功,但是端口确不是使用的基座的端口,如何解决

我的基座pom配置

<?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>

    <groupId>com.benjamin</groupId>
    <artifactId>benjamin-koup-base</artifactId>
    <version>1.0.0</version>
    <packaging>jar</packaging>

    <name>benjamin-koup-base</name>
    <description>Koupleless Base Application</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.18</version>
        <relativePath/>
    </parent>

    <properties>
        <java.version>8</java.version>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <spring-boot.version>2.7.18</spring-boot.version>
        <sofa.ark.version>2.2.16</sofa.ark.version>
        <koupleless.runtime.version>1.3.3</koupleless.runtime.version>
    </properties>

    <dependencies>
        <!-- Spring Boot Starter Web -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!-- Koupleless 基座 Starter(包含Arklet,无需单独添加) -->
        <dependency>
            <groupId>com.alipay.sofa.koupleless</groupId>
            <artifactId>koupleless-base-starter</artifactId>
            <version>${koupleless.runtime.version}</version>
        </dependency>

        <!-- Web Ark Plugin - 支持多web模块合并部署 -->
        <dependency>
            <groupId>com.alipay.sofa</groupId>
            <artifactId>web-ark-plugin</artifactId>
            <version>${sofa.ark.version}</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!-- Spring Boot 打包插件 -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${spring-boot.version}</version>
                <configuration>
                    <mainClass>com.benjamin.base.BenjaminBaseApplication</mainClass>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Koupleless 基座构建插件 -->
            <plugin>
                <groupId>com.alipay.sofa.koupleless</groupId>
                <artifactId>koupleless-base-build-plugin</artifactId>
                <version>${koupleless.runtime.version}</version>
                <executions>
                    <execution>
                        <id>generate-dependencies</id>
                        <goals>
                            <goal>packageDependency</goal>
                        </goals>
                        <phase>package</phase>
                    </execution>
                    <execution>
                        <goals>
                            <goal>add-patch</goal>
                            <goal>integrate-biz</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <dependencyGroupId>${project.groupId}</dependencyGroupId>
                    <dependencyArtifactId>base-dependencies-starter</dependencyArtifactId>
                    <dependencyVersion>1.0.0</dependencyVersion>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>


我的模块pom配置

<?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继承base-dependencies-starter -->
    <!-- 模块的parent保持为spring-boot-starter-parent,通过baseDependencyParentIdentity实现瘦身 -->

    <groupId>com.benjamin</groupId>
    <artifactId>benjamin-koup-biz</artifactId>
    <version>1.0.0</version>
    <packaging>jar</packaging>

    <name>benjamin-koup-biz</name>
    <description>Koupleless Biz Module</description>

    <parent>
        <groupId>com.benjamin</groupId>
        <artifactId>base-dependencies-starter</artifactId>
        <version>1.0.0</version>
    </parent>

    <properties>
        <java.version>8</java.version>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <spring-boot.version>2.7.18</spring-boot.version>
        <sofa.ark.version>2.2.16</sofa.ark.version>
        <koupleless.runtime.version>1.3.3</koupleless.runtime.version>
    </properties>

    <dependencies>
        <!-- Spring Boot Starter Web -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- Koupleless 模块 Starter (provided,由基座提供) -->
        <dependency>
            <groupId>com.alipay.sofa.koupleless</groupId>
            <artifactId>koupleless-app-starter</artifactId>
            <version>${koupleless.runtime.version}</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!-- SOFA Ark 打包插件 -->
            <plugin>
                <groupId>com.alipay.sofa</groupId>
                <artifactId>sofa-ark-maven-plugin</artifactId>
                <version>${sofa.ark.version}</version>
                <executions>
                    <execution>
                        <id>default-cli</id>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <skipArkExecutable>false</skipArkExecutable>
                    <outputDirectory>./target</outputDirectory>
                    <bizName>benjamin-koup-biz</bizName>
                    <bizVersion>${project.version}</bizVersion>
                    <!-- 模块的web访问路径,部署后通过 /biz 访问 -->
                    <webContextPath>biz</webContextPath>
                    <!-- 声明模式,开启精确类加载隔离 -->
                    <declaredMode>true</declaredMode>
                    <!-- 指向基座生成的依赖 starter,实现自动瘦身[citation:9] -->
                    <baseDependencyParentIdentity>com.benjamin:base-dependencies-starter:1.0.0</baseDependencyParentIdentity>
                </configuration>
            </plugin>

            <!-- Spring Boot 打包插件(用于独立启动测试) -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${spring-boot.version}</version>
            </plugin>
        </plugins>
    </build>
</project>


启动基座日志

java "-Dsofa.ark.unpack.biz.when.install=false" -jar "-Dkoupleless.arklet.http.port=1237" target/benjamin-koup-base-1.0.0.jar
10:41:04.600 [main] DEBUG io.netty.util.internal.logging.InternalLoggerFactory - Using SLF4J as the default logging framework
10:41:04.603 [main] DEBUG io.netty.channel.MultithreadEventLoopGroup - -Dio.netty.eventLoopThreads: 24
10:41:04.612 [main] DEBUG io.netty.util.concurrent.GlobalEventExecutor - -Dio.netty.globalEventExecutor.quietPeriodSeconds: 1
10:41:04.621 [main] DEBUG io.netty.util.internal.InternalThreadLocalMap - -Dio.netty.threadLocalMap.stringBuilder.initialSize: 1024
10:41:04.621 [main] DEBUG io.netty.util.internal.InternalThreadLocalMap - -Dio.netty.threadLocalMap.stringBuilder.maxSize: 4096
10:41:04.647 [main] DEBUG io.netty.util.internal.PlatformDependent0 - -Dio.netty.noUnsafe: false
10:41:04.647 [main] DEBUG io.netty.util.internal.PlatformDependent0 - Java version: 8
10:41:04.648 [main] DEBUG io.netty.util.internal.PlatformDependent0 - sun.misc.Unsafe.theUnsafe: available
10:41:04.648 [main] DEBUG io.netty.util.internal.PlatformDependent0 - sun.misc.Unsafe.copyMemory: available
10:41:04.649 [main] DEBUG io.netty.util.internal.PlatformDependent0 - sun.misc.Unsafe.storeFence: available
10:41:04.649 [main] DEBUG io.netty.util.internal.PlatformDependent0 - java.nio.Buffer.address: available
10:41:04.650 [main] DEBUG io.netty.util.internal.PlatformDependent0 - direct buffer constructor: available
10:41:04.650 [main] DEBUG io.netty.util.internal.PlatformDependent0 - java.nio.Bits.unaligned: available, true
10:41:04.651 [main] DEBUG io.netty.util.internal.PlatformDependent0 - jdk.internal.misc.Unsafe.allocateUninitializedArray(int): unavailable prior to Java9
10:41:04.651 [main] DEBUG io.netty.util.internal.PlatformDependent0 - java.nio.DirectByteBuffer.<init>(long, {int,long}): available
10:41:04.651 [main] DEBUG io.netty.util.internal.PlatformDependent - sun.misc.Unsafe: available
10:41:04.651 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.tmpdir: C:\Users\ADMINI~1\AppData\Local\Temp (java.io.tmpdir)
10:41:04.651 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.bitMode: 64 (sun.arch.data.model)
10:41:04.651 [main] DEBUG io.netty.util.internal.PlatformDependent - Platform: Windows
10:41:04.652 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.maxDirectMemory: 7592738816 bytes
10:41:04.652 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.uninitializedArrayAllocationThreshold: -1
10:41:04.654 [main] DEBUG io.netty.util.internal.CleanerJava6 - java.nio.ByteBuffer.cleaner(): available
10:41:04.655 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.noPreferDirect: false
10:41:04.655 [main] DEBUG io.netty.channel.nio.NioEventLoop - -Dio.netty.noKeySetOptimization: false
10:41:04.655 [main] DEBUG io.netty.channel.nio.NioEventLoop - -Dio.netty.selectorAutoRebuildThreshold: 512
10:41:04.664 [main] DEBUG io.netty.util.internal.PlatformDependent - org.jctools-core.MpscChunkedArrayQueue: available
10:41:05.174 [main] DEBUG io.netty.channel.DefaultChannelId - -Dio.netty.processId: 26152 (auto-detected)
10:41:05.176 [main] DEBUG io.netty.util.NetUtil - -Djava.net.preferIPv4Stack: false
10:41:05.176 [main] DEBUG io.netty.util.NetUtil - -Djava.net.preferIPv6Addresses: false
10:41:05.581 [main] DEBUG io.netty.util.NetUtilInitializations - Loopback interface: lo (Software Loopback Interface 1, 127.0.0.1)
10:41:05.582 [main] DEBUG io.netty.util.NetUtil - Failed to get SOMAXCONN from sysctl and file \proc\sys\net\core\somaxconn. Default: 200
10:41:05.608 [main] DEBUG io.netty.channel.DefaultChannelId - -Dio.netty.machineId: c8:7f:54:ff:fe:a9:f1:af (auto-detected)
10:41:05.621 [main] DEBUG io.netty.util.ResourceLeakDetector - -Dio.netty.leakDetection.level: simple
10:41:05.621 [main] DEBUG io.netty.util.ResourceLeakDetector - -Dio.netty.leakDetection.targetRecords: 4
10:41:05.644 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.numHeapArenas: 24
10:41:05.644 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.numDirectArenas: 24
10:41:05.644 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.pageSize: 8192
10:41:05.644 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.maxOrder: 9
10:41:05.644 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.chunkSize: 4194304
10:41:05.644 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.smallCacheSize: 256
10:41:05.644 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.normalCacheSize: 64
10:41:05.644 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.maxCachedBufferCapacity: 32768
10:41:05.644 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.cacheTrimInterval: 8192
10:41:05.644 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.cacheTrimIntervalMillis: 0
10:41:05.644 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.useCacheForAllThreads: false
10:41:05.644 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.maxCachedByteBuffersPerChunk: 1023
10:41:05.656 [main] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.allocator.type: pooled
10:41:05.656 [main] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.threadLocalDirectBufferSize: 0
10:41:05.657 [main] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.maxThreadLocalCharBufferSize: 16384
10:41:05.659 [main] DEBUG io.netty.bootstrap.ChannelInitializerExtensions - -Dio.netty.bootstrap.extensions: null
10:41:05.672 [SOFA-ARK-telnet-server-worker-0-T1] INFO io.netty.handler.logging.LoggingHandler - [id: 0x093cc7c6] REGISTERED
10:41:05.673 [SOFA-ARK-telnet-server-worker-0-T1] INFO io.netty.handler.logging.LoggingHandler - [id: 0x093cc7c6] BIND: 0.0.0.0/0.0.0.0:1234
10:41:05.676 [SOFA-ARK-telnet-server-worker-0-T1] INFO io.netty.handler.logging.LoggingHandler - [id: 0x093cc7c6, L:/0:0:0:0:0:0:0:0:1234] ACTIVE
Ark container started in 1682 ms.

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::               (v2.7.18)

2026-04-03 10:41:05.848  INFO 26152 --- [           main] c.benjamin.base.BenjaminBaseApplication  : Starting BenjaminBaseApplication v1.0.0 using Java 1.8.0_361 on LPDN with PID 26152 (D:\javasource\benjamin-koup\benjamin-koup-base\target\benjamin-koup-base-1.0.0.jar started by Administrator in D:\javasource\benjamin-koup\benjamin-koup-base)
2026-04-03 10:41:05.850  INFO 26152 --- [           main] c.benjamin.base.BenjaminBaseApplication  : No active profile set, falling back to 1 default profile: "default"
2026-04-03 10:41:06.441  INFO 26152 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'com.alipay.sofa.koupleless.plugin.BaseRuntimeAutoConfiguration' of type [com.alipay.sofa.koupleless.plugin.BaseRuntimeAutoConfiguration$$EnhancerBySpringCGLIB$$e43d7a27] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2026-04-03 10:41:06.666  WARN 26152 --- [           main] o.apache.catalina.core.StandardContext   : A context path must either be an empty string or start with a '/' and do not end with a '/'. The path [/] does not meet these criteria and has been changed to []
2026-04-03 10:41:06.676  INFO 26152 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8083 (http)
2026-04-03 10:41:06.784  INFO 26152 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2026-04-03 10:41:06.785  INFO 26152 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.83]
2026-04-03 10:41:06.926  INFO 26152 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2026-04-03 10:41:06.926  INFO 26152 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1047 ms
2026-04-03 10:41:07.321  INFO 26152 --- [           main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 1 endpoint(s) beneath base path '/actuator'
2026-04-03 10:41:07.345  INFO 26152 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8083 (http) with context path ''
2026-04-03 10:41:07.862  INFO 26152 --- [           main] arklet : found components: CommandServiceImpl, ApiClient, UnifiedOperationServiceImpl, HealthServiceImpl
2026-04-03 10:41:07.866  INFO 26152 --- [           main] arklet : start to initialize components
2026-04-03 10:41:07.867  INFO 26152 --- [           main] arklet : registered command:installBiz
2026-04-03 10:41:07.867  INFO 26152 --- [           main] arklet : registered command:help
2026-04-03 10:41:07.867  INFO 26152 --- [           main] arklet : registered command:queryAllBiz
2026-04-03 10:41:07.868  INFO 26152 --- [           main] arklet : registered command:uninstallBiz
2026-04-03 10:41:07.868  INFO 26152 --- [           main] arklet : registered command:switchBiz
2026-04-03 10:41:07.868  INFO 26152 --- [           main] arklet : registered command:health
2026-04-03 10:41:07.868  INFO 26152 --- [           main] arklet : registered command:queryBizOps
2026-04-03 10:41:07.868  INFO 26152 --- [           main] arklet : http tunnel initialized: com.alipay.sofa.koupleless.arklet.core.api.tunnel.http.HttpTunnel@791d1f8b
2026-04-03 10:41:07.869  INFO 26152 --- [           main] arklet : http tunnel listening on port: 1237
2026-04-03 10:41:08.294  INFO 26152 --- [ntLoopGroup-2-1] io.netty.handler.logging.LoggingHandler  : [id: 0x610dc553] REGISTERED
2026-04-03 10:41:08.295  INFO 26152 --- [ntLoopGroup-2-1] io.netty.handler.logging.LoggingHandler  : [id: 0x610dc553] BIND: 0.0.0.0/0.0.0.0:1237
2026-04-03 10:41:08.296  INFO 26152 --- [ntLoopGroup-2-1] io.netty.handler.logging.LoggingHandler  : [id: 0x610dc553, L:/0:0:0:0:0:0:0:0:1237] ACTIVE
2026-04-03 10:41:09.074  INFO 26152 --- [           main] arklet : register indicator cpu
2026-04-03 10:41:09.074  INFO 26152 --- [           main] arklet : register indicator jvm
2026-04-03 10:41:09.074  INFO 26152 --- [           main] arklet : finish initialize components
2026-04-03 10:41:09.075  INFO 26152 --- [           main] arklet : total supported commands:health, queryAllBiz, help, uninstallBiz, switchBiz, installBiz, queryBizOps
2026-04-03 10:41:09.077  INFO 26152 --- [           main] c.benjamin.base.BenjaminBaseApplication  : Started BenjaminBaseApplication in 5.286 seconds (JVM running for 5.629)
========================================
   Benjamin Koupleless Base Started!    
========================================

模块部署脚本日志

========================================
  Benjamin Koupleless - Deploy Module
========================================

[INFO] Deploying module via Arklet API...
  Biz Name: benjamin-koup-biz
  Biz Version: 1.0.0
  Biz URL: file:///D:/javasource/benjamin-koup/scripts/../benjamin-koup-biz/target/benjamin-koup-biz-1.0.0-ark-biz.jar

{"baseIdentity":"172.31.0.1","code":"SUCCESS","data":{"bizInfos":[{"attributes":{},"bizName":"benjamin-koup-biz","bizState":"activated","bizStateRecords":[{"changeTime":1775184954755,"message":"","reason":"Created","state":"resolved"},{"changeTime":1775184955901,"message":"","reason":"Started","state":"activated"}],"bizTempWorkDir":"C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\sofa-ark\\benjamin-koup-biz-1.0.0-20260403105554743","bizUrl":"jar:file:/C:/Users/ADMINI~1/AppData/Local/Temp/sofa-ark/benjamin-koup-biz-1.0.0-20260403105554743!/","bizVersion":"1.0.0","classPath":["jar:file:/C:/Users/ADMINI~1/AppData/Local/Temp/sofa-ark/benjamin-koup-biz-1.0.0-20260403105554743!/"],"declaredMode":true,"denyImportClasses":[],"denyImportPackageNodes":[],"denyImportPackageStems":[],"denyImportPackages":[],"denyImportResources":[],"denyPrefixImportResourceStems":[],"denySuffixImportResourceStems":[],"identity":"benjamin-koup-biz:1.0.0","injectExportPackages":[],"injectPluginDependencies":[],"mainClass":"com.benjamin.biz.BenjaminBizApplication","priority":100,"webContextPath":"biz"}],"code":"SUCCESS","elapsedSpace":1092184,"message":"Install Biz: benjamin-koup-biz:1.0.0 success, cost: 1151 ms, started at: 10:55:54,750"}}

[INFO] Verifying deployment...
{"baseIdentity":"172.31.0.1","code":"SUCCESS","data":[{"bizName":"benjamin-koup-biz","bizState":"activated","bizStateRecords":[{"changeTime":1775184954755,"message":"","reason":"Created","state":"resolved"},{"changeTime":1775184955901,"message":"","reason":"Started","state":"activated"}],"bizVersion":"1.0.0","mainClass":"com.benjamin.biz.BenjaminBizApplication","webContextPath":"biz"}]}
========================================
  Deployment completed
========================================

模块部署基座中的日志


2026-04-03 10:55:54.528  INFO 26152 --- [ntLoopGroup-2-1] io.netty.handler.logging.LoggingHandler  : [id: 0x610dc553, L:/0:0:0:0:0:0:0:0:1237] READ: [id: 0x8b463366, L:/127.0.0.1:1237 - R:/127.0.0.1:60514]
2026-04-03 10:55:54.529  INFO 26152 --- [ntLoopGroup-2-1] io.netty.handler.logging.LoggingHandler  : [id: 0x610dc553, L:/0:0:0:0:0:0:0:0:1237] READ COMPLETE
2026-04-03 10:55:54.723  INFO 26152 --- [ntLoopGroup-3-1] arklet : start to process command installBiz with parameters {bizName=benjamin-koup-biz, bizUrl=file:///D:/javasource/benjamin-koup/scripts/../benjamin-koup-biz/target/benjamin-koup-biz-1.0.0-ark-biz.jar, bizVersion=1.0.0}
2026-04-03 10:55:54.742  INFO 26152 --- [ntLoopGroup-3-1] arklet : start to install biz: benjamin-koup-biz,1.0.0,file:///D:/javasource/benjamin-koup/scripts/../benjamin-koup-biz/target/benjamin-koup-biz-1.0.0-ark-biz.jar
2026-04-03 10:55:55.248  INFO 26152 --- [ntLoopGroup-3-1] k.p.s.ServerlessEnvironmentPostProcessor : register master biz property source to biz, shareKeys: []

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::               (v2.7.18)

2026-04-03 10:55:55.256  INFO 26152 --- [ntLoopGroup-3-1] o.s.boot.SpringApplication               : Starting application using Java 1.8.0_361 on LPDN with PID 26152 (D:\javasource\benjamin-koup\benjamin-koup-base\target\benjamin-koup-base-1.0.0.jar started by Administrator in D:\javasource\benjamin-koup\benjamin-koup-base)
2026-04-03 10:55:55.256  INFO 26152 --- [ntLoopGroup-3-1] o.s.boot.SpringApplication               : No active profile set, falling back to 1 default profile: "default"
2026-04-03 10:55:55.768  INFO 26152 --- [ntLoopGroup-3-1] trationDelegate$BeanPostProcessorChecker : Bean 'com.alipay.sofa.koupleless.plugin.BaseRuntimeAutoConfiguration' of type [com.alipay.sofa.koupleless.plugin.BaseRuntimeAutoConfiguration$$EnhancerBySpringCGLIB$$e43d7a27] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2026-04-03 10:55:55.782  WARN 26152 --- [ntLoopGroup-3-1] o.apache.catalina.core.StandardContext   : A context path must either be an empty string or start with a '/' and do not end with a '/'. The path [biz] does not meet these criteria and has been changed to [/biz]
2026-04-03 10:55:55.783  INFO 26152 --- [ntLoopGroup-3-1] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2026-04-03 10:55:55.784  INFO 26152 --- [ntLoopGroup-3-1] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2026-04-03 10:55:55.784  INFO 26152 --- [ntLoopGroup-3-1] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.83]
2026-04-03 10:55:55.792  INFO 26152 --- [ntLoopGroup-3-1] o.a.c.c.C.[Tomcat-1].[localhost].[biz]   : Initializing Spring embedded WebApplicationContext
2026-04-03 10:55:55.792  INFO 26152 --- [ntLoopGroup-3-1] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 534 ms
2026-04-03 10:55:55.885  INFO 26152 --- [ntLoopGroup-3-1] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 1 endpoint(s) beneath base path '/actuator'
2026-04-03 10:55:55.891  INFO 26152 --- [ntLoopGroup-3-1] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path '/biz'
2026-04-03 10:55:55.897  INFO 26152 --- [ntLoopGroup-3-1] o.s.boot.SpringApplication               : Started application in 0.669 seconds (JVM running for 892.458)
========================================
   Benjamin Koupleless Biz Started!     
   Biz Name: benjamin-koup-biz          
   Version: 1.0.0                       
========================================
2026-04-03 10:55:57.171  INFO 26152 --- [ntLoopGroup-2-1] io.netty.handler.logging.LoggingHandler  : [id: 0x610dc553, L:/0:0:0:0:0:0:0:0:1237] READ: [id: 0x68149cd0, L:/127.0.0.1:1237 - R:/127.0.0.1:60518]
2026-04-03 10:55:57.171  INFO 26152 --- [ntLoopGroup-2-1] io.netty.handler.logging.LoggingHandler  : [id: 0x610dc553, L:/0:0:0:0:0:0:0:0:1237] READ COMPLETE
2026-04-03 10:55:57.173  INFO 26152 --- [ntLoopGroup-3-2] arklet : start to process command queryAllBiz with parameters {}

我的基座端口是8083,但是模块部署时使用的8080。我的操作环境为windows,java版本1.8.0_361,maven版本3.9.9
麻烦能帮忙解决下吗,可以有偿,谢谢

  • 写回答

3条回答 默认 最新

  • 檀越@新空间 2026-04-03 11:10
    关注

    上午好☀️☀️☀️️
    本答案参考通义千问

    你提到的问题是关于 Koupleless 框架中基座(Base)和动态模块(Dynamic Module)部署后,模块使用的端口不是基座的端口。这表明你的模块可能没有正确地与基座进行集成,或者其配置被独立设置,导致它运行在自己的端口上。


    问题分析

    1. Koupleless 的工作原理

      • 在 Koupleless 中,基座负责管理多个动态模块。
      • 动态模块应通过基座启动,并共享基座的资源(包括端口、配置等)。
      • 如果模块运行在自己的端口上,说明它可能被单独打包或运行,而不是作为基座的一部分。
    2. 常见原因

      • 模块未正确依赖基座:模块没有引用基座的依赖项,导致其独立运行。
      • 模块未使用 koupleless-dynamic-module-starter:缺少此依赖会导致模块无法被基座识别为动态模块。
      • 模块配置文件未指定基座的配置:如 application.yml 中未指定正确的端口或绑定到基座的配置。
      • 模块被单独运行:可能是通过 java -jar 或其他方式直接运行模块,而不是通过基座加载。

    解决方案

    1. 确保模块依赖基座

    • 修改模块的 pom.xml 文件,确保它包含对基座的依赖(例如:base-dependencies-starter)。
    <dependency>
        <groupId>com.benjamin</groupId>
        <artifactId>base-dependencies-starter</artifactId>
        <version>1.0.0</version>
    </dependency>
    

    注意: 这个依赖需要在基座中定义并发布到本地或远程仓库。


    2. 添加 koupleless-dynamic-module-starter 依赖

    • 模块必须依赖 koupleless-dynamic-module-starter,否则它不会被识别为动态模块。
    <dependency>
        <groupId>com.alipay.sofa.koupleless</groupId>
        <artifactId>koupleless-dynamic-module-starter</artifactId>
        <version>${koupleless.runtime.version}</version>
    </dependency>
    

    3. 配置模块使用基座的配置

    • 在模块的 application.ymlapplication.properties 中,确保不设置独立的端口。如果设置了,可能会覆盖基座的配置。
    server:
      port: 8080  # ❌ 不建议设置,除非你确实要覆盖基座的端口
    

    建议:不要设置 server.port,让模块继承基座的配置。


    4. 确保模块通过基座启动

    • 基座的主类应该包含对模块的扫描和加载逻辑。
    • 使用 @KouplelessBootApplication 注解基座主类:
    @SpringBootApplication
    @KouplelessBootApplication
    public class BenjaminBaseApplication {
        public static void main(String[] args) {
            SpringApplication.run(BenjaminBaseApplication.class, args);
        }
    }
    

    5. 验证模块是否被正确加载

    • 查看基座的日志,确认模块是否成功加载。
    • 检查模块的 META-INF/koupleless/dynamic-module-info.json 文件是否存在,内容如下:
    {
      "moduleName": "module-name",
      "mainClass": "com.benjamin.module.ModuleMain"
    }
    

    6. 构建基座和模块时使用统一的版本号

    • 确保基座和模块的版本号一致,避免因版本冲突导致模块未被加载。

    ✅ 修改后的模块 pom.xml 示例

    <?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>
    
        <groupId>com.benjamin</groupId>
        <artifactId>benjamin-koup-module</artifactId>
        <version>1.0.0</version>
        <packaging>jar</packaging>
    
        <name>benjamin-koup-module</name>
        <description>Koupleless Dynamic Module</description>
    
        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.7.18</version>
            <relativePath/>
        </parent>
    
        <properties>
            <java.version>8</java.version>
            <maven.compiler.source>8</maven.compiler.source>
            <maven.compiler.target>8</maven.compiler.target>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <spring-boot.version>2.7.18</spring-boot.version>
            <koupleless.runtime.version>1.3.3</koupleless.runtime.version>
        </properties>
    
        <dependencies>
            <!-- Spring Boot Starter Web -->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
    
            <!-- Koupleless 动态模块依赖 -->
            <dependency>
                <groupId>com.alipay.sofa.koupleless</groupId>
                <artifactId>koupleless-dynamic-module-starter</artifactId>
                <version>${koupleless.runtime.version}</version>
            </dependency>
    
            <!-- 基座依赖(确保已发布到仓库) -->
            <dependency>
                <groupId>com.benjamin</groupId>
                <artifactId>base-dependencies-starter</artifactId>
                <version>1.0.0</version>
            </dependency>
        </dependencies>
    
        <build>
            <plugins>
                <!-- Spring Boot 打包插件 -->
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <version>${spring-boot.version}</version>
                    <configuration>
                        <mainClass>com.benjamin.module.ModuleMain</mainClass>
                    </configuration>
                    <executions>
                        <execution>
                            <goals>
                                <goal>repackage</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </project>
    

    总结

    | 步骤 | 内容 | |------|------| | 1 | 确保模块依赖基座的依赖项 | | 2 | 添加 koupleless-dynamic-module-starter 依赖 | | 3 | 不设置模块的 server.port,让它继承基座配置 | | 4 | 基座主类使用 @KouplelessBootApplication 注解 | | 5 | 验证模块是否被基座正确加载 | | 6 | 构建时保持版本一致性 |


    如果你仍然遇到问题,请提供以下信息:

    • 基座和模块的日志输出;
    • 模块的 application.ymlapplication.properties 文件内容;
    • 你是如何启动基座和模块的(命令行、IDE、Maven 命令等)。

    我可以进一步帮你定位问题!

    评论

报告相同问题?

问题事件

  • 创建了问题 4月3日