sofastack / sofa-ark

SOFAArk is a light-weight,java based classloader isolation framework.
https://www.sofastack.tech/projects/sofa-boot/sofa-ark-readme/
Apache License 2.0
1.57k stars 504 forks source link

基座 jar 包无法读取 conf/ark/bootstrap.properties 自定义配置 #1021

Open gaosaroma opened 2 weeks ago

gaosaroma commented 2 weeks ago

Feature description

现状

在 SOFA-ARK 2.0+ 中,基座启动 ArkContainer 时,将通过 ContainerClassLoader 读取自定义配置。但 ContainerClassLoader 的 ucp 仅有基座 resources/conf/ark 目录、 sofa-ark-all 及其依赖,从而无法读取用户自定义配置,见:

需求

支持读取用户基座中 conf/ark/bootstrap.properties 作为自定义配置。

Additional notes

Add other notes if necessary.

gaosaroma commented 2 weeks ago

解决方式:

在基座打包时,可以通过 maven-resources-plugin 把 conf 资源打包到 jar 包中,如:

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-resources</id>
                        <!-- here the phase you need -->
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${basedir}/target/classes/conf/ark</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${basedir}/conf/ark</directory>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>