GraalVM 无​​法使用数据库连接

2024-03-01

我正在尝试使用 Graalvm 构建本机映像,但每次尝试使用 mvn gluonfx:build 并在项目中使用数据库连接构建它时,都会出现错误,例如:H2 DB。

  • 正常运行就可以了
  • 无需任何数据库连接,本机映像已成功构建

这是pom文件的代码

<groupId>com.example</groupId>
<artifactId>demo1</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>demo1</name>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.release>11</maven.compiler.release>
    <javafx.version>17.0.0.1</javafx.version>
    <attach.version>4.0.12</attach.version>
    <gluonfx.plugin.version>1.0.15</gluonfx.plugin.version>
    <javafx.plugin.version>0.0.7</javafx.plugin.version>
    <main.class>com.example.demo1.main.Driver</main.class>
    <junit.version>5.7.1</junit.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-controls</artifactId>
        <version>${javafx.version}</version>
        <exclusions>
            <exclusion>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-graphics</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-media</artifactId>
        <version>${javafx.version}</version>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-fxml</artifactId>
        <version>${javafx.version}</version>
        <exclusions>
            <exclusion>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-controls</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>com.gluonhq</groupId>
        <artifactId>charm-glisten</artifactId>
        <version>6.0.6</version>
    </dependency>
    <dependency>
        <groupId>com.gluonhq.attach</groupId>
        <artifactId>display</artifactId>
        <version>${attach.version}</version>
    </dependency>
    <dependency>
        <groupId>com.gluonhq.attach</groupId>
        <artifactId>lifecycle</artifactId>
        <version>${attach.version}</version>
    </dependency>
    <dependency>
        <groupId>com.gluonhq.attach</groupId>
        <artifactId>statusbar</artifactId>
        <version>${attach.version}</version>
    </dependency>
    <dependency>
        <groupId>com.gluonhq.attach</groupId>
        <artifactId>storage</artifactId>
        <version>${attach.version}</version>
    </dependency>
    <dependency>
        <groupId>com.gluonhq.attach</groupId>
        <artifactId>util</artifactId>
        <version>${attach.version}</version>
    </dependency>
    <dependency>
        <groupId>org.bytedeco</groupId>
        <artifactId>javacpp</artifactId>
        <version>1.5.6</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>5.0.0</version>
    </dependency>
    <dependency>
        <groupId>net.jthink</groupId>
        <artifactId>jaudiotagger</artifactId>
        <version>3.0.1</version>
    </dependency>
    <dependency>
        <groupId>com.googlecode.soundlibs</groupId>
        <artifactId>jlayer</artifactId>
        <version>1.0.1.4</version>
    </dependency>
    <dependency>
        <groupId>com.googlecode.soundlibs</groupId>
        <artifactId>mp3spi</artifactId>
        <version>1.9.5-1</version>
        <exclusions>
            <exclusion>
                <groupId>com.googlecode.soundlibs</groupId>
                <artifactId>tritonus-share</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>com.googlecode.soundlibs</groupId>
        <artifactId>tritonus-share</artifactId>
        <version>0.3.7.4</version>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <version>2.1.214</version>
    </dependency>

</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
        </plugin>
        <plugin>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-maven-plugin</artifactId>
            <version>${javafx.plugin.version}</version>
            <configuration>
                <mainClass>${main.class}</mainClass>
            </configuration>
        </plugin>
        <plugin>
            <groupId>com.gluonhq</groupId>
            <artifactId>gluonfx-maven-plugin</artifactId>
            <version>${gluonfx.plugin.version}</version>
            <configuration>
                <target>${gluonfx.target}</target>
                <nativeImageArgs>
                    <nativeImageArg>--allow-incomplete-classpath</nativeImageArg>
                </nativeImageArgs>
                <attachList>
                    <list>display</list>
                    <list>lifecycle</list>
                    <list>statusbar</list>
                    <list>storage</list>
                </attachList>
                <mainClass>${main.class}</mainClass>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-maven-plugin</artifactId>
            <version>0.0.7</version>
            <executions>
                <execution>
                    <!-- Default configuration for running with: mvn clean javafx:run -->
                    <id>default-cli</id>
                    <configuration>
                        <mainClass>com.example.demo1/com.example.demo1.HelloApplication</mainClass>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
<profiles>
    <profile>
        <id>ios</id>
        <properties>
            <gluonfx.target>ios</gluonfx.target>
        </properties>
    </profile>
    <profile>
        <id>android</id>
        <properties>
            <gluonfx.target>android</gluonfx.target>
        </properties>
    </profile>
</profiles>
<repositories>
    <repository>
        <id>gluon-releases</id>
        <url>https://nexus.gluonhq.com/nexus/content/repositories/releases/</url>
    </repository>
</repositories>

这是主类

package com.example.demo1.main;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.stage.Stage;

import java.sql.Connection;
import java.sql.DriverManager;

public class Driver extends Application {
@Override
public void start(Stage stage) throws Exception {
    Class.forName("org.h2.Driver");
    String str = "";
    Connection con= DriverManager.getConnection(
            "","","");
        str = str + con + "\n";
    con.close();
    Scene scene = new Scene(new Label(str),500,500);
    stage.setScene(scene);
    stage.show();
}

public static void main(String[] args) {
    launch(args);
}
}

这是错误:

[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for com.example:demo1:jar:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration of plugin org.openjfx:javafx-maven-plugin @ line 159, column 21
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO] 
[INFO] -------------------------< com.example:demo1 >--------------------------
[INFO] Building demo1 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- gluonfx-maven-plugin:1.0.15:build (default-cli) @ demo1 ---
[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for com.example:demo1:jar:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration of plugin org.openjfx:javafx-maven-plugin @ line 159, column 21
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO] 
[INFO] -------------------------< com.example:demo1 >--------------------------
[INFO] Building demo1 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] >>> gluonfx-maven-plugin:1.0.15:compile (default-cli) > process-classes @ demo1 >>>
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ demo1 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ demo1 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 4 source files to /Users/yousefhamarsheh/Desktop/demo1/target/classes
[INFO] 
[INFO] <<< gluonfx-maven-plugin:1.0.15:compile (default-cli) < process-classes @ demo1 <<<
[INFO] 
[INFO] 
[INFO] --- gluonfx-maven-plugin:1.0.15:compile (default-cli) @ demo1 ---
Aug 30, 2022 12:20:55 PM com.gluonhq.substrate.util.Logger logInfo
INFO: Substrate is tested with the Gluon's GraalVM build which you can find at https://github.com/gluonhq/graal/releases.
While you can still use other GraalVM builds, there is no guarantee that these will work properly with Substrate
[Tue Aug 30 12:20:55 EEST 2022][INFO] ==================== COMPILE TASK ====================
             _______  ___      __   __  _______  __    _
            |       ||   |    |  | |  ||       ||  |  | |
            |    ___||   |    |  | |  ||   _   ||   |_| |
            |   | __ |   |    |  |_|  ||  | |  ||       |
            |   ||  ||   |___ |       ||  |_|  ||  _    |
            |   |_| ||       ||       ||       || | |   |
            |_______||_______||_______||_______||_|  |__|

    Access to the latest docs, tips and tricks and more info on
    how to get support? Register your usage of Gluon Substrate now at

    https://gluonhq.com/activate



[Tue Aug 30 12:20:56 EEST 2022][INFO] We will now compile your code for aarch64-apple-darwin. This may take some time.
[Tue Aug 30 12:20:57 EEST 2022][INFO] [SUB] Warning: Ignoring server-mode native-image argument --no-server.
[Tue Aug 30 12:20:57 EEST 2022][INFO] [SUB] Warning: Using a deprecated option --allow-incomplete-classpath from command line. Allowing an incomplete classpath is now the default. Use --link-at-build-time to report linking errors at image build time for a class or package.
[Tue Aug 30 12:21:01 EEST 2022][INFO] [SUB] ========================================================================================================================
[Tue Aug 30 12:21:01 EEST 2022][INFO] [SUB] GraalVM Native Image: Generating 'com.example.demo1.main.driver' (shared library)...
[Tue Aug 30 12:21:01 EEST 2022][INFO] [SUB] ========================================================================================================================
[Tue Aug 30 12:21:05 EEST 2022][INFO] [SUB] [1/7] Initializing...                                                                                    (6.6s @ 0.21GB)
[Tue Aug 30 12:21:05 EEST 2022][INFO] [SUB]  Version info: 'GraalVM 22.2.0 Java 17 CE'
[Tue Aug 30 12:21:05 EEST 2022][INFO] [SUB]  Java version info: '17.0.4+8-jvmci-22.2-b06'
[Tue Aug 30 12:21:05 EEST 2022][INFO] [SUB]  C compiler: cc (apple, arm64, 13.0.0)
[Tue Aug 30 12:21:05 EEST 2022][INFO] [SUB]  Garbage collector: Serial GC
[Tue Aug 30 12:21:05 EEST 2022][INFO] [SUB]  1 user-specific feature(s)
[Tue Aug 30 12:21:05 EEST 2022][INFO] [SUB]  - org.graalvm.home.HomeFinderFeature: Finds GraalVM paths and its version number
[Tue Aug 30 12:22:08 EEST 2022][INFO] [SUB] [2/7] Performing analysis...  [*********]                                                               (63.3s @ 2.08GB)
[Tue Aug 30 12:22:08 EEST 2022][INFO] [SUB]   13,955 (91.53%) of 15,247 classes reachable
[Tue Aug 30 12:22:08 EEST 2022][INFO] [SUB]   27,104 (69.81%) of 38,823 fields reachable
[Tue Aug 30 12:22:08 EEST 2022][INFO] [SUB]   72,186 (66.16%) of 109,109 methods reachable
[Tue Aug 30 12:22:08 EEST 2022][INFO] [SUB]      675 classes,   185 fields, and 2,214 methods registered for reflection
[Tue Aug 30 12:22:08 EEST 2022][INFO] [SUB]      118 classes,   111 fields, and   193 methods registered for JNI access
[Tue Aug 30 12:22:08 EEST 2022][INFO] [SUB]        5 native libraries: -framework CoreServices, -framework Foundation, dl, pthread, z
[Tue Aug 30 12:22:19 EEST 2022][INFO] [SUB] [3/7] Building universe...                                                                              (10.9s @ 1.39GB)
[Tue Aug 30 12:22:29 EEST 2022][INFO] [SUB] [4/7] Parsing methods...      [***]                                                                      (9.2s @ 2.57GB)
[Tue Aug 30 12:22:37 EEST 2022][INFO] [SUB] [5/7] Inlining methods...     [****]                                                                     (7.1s @ 1.74GB)
[Tue Aug 30 12:23:41 EEST 2022][INFO] [SUB] [6/7] Compiling methods...    [********]                                                                (64.5s @ 3.11GB)
[Tue Aug 30 12:24:01 EEST 2022][INFO] [SUB] 
[Tue Aug 30 12:24:01 EEST 2022][INFO] [SUB] ------------------------------------------------------------------------------------------------------------------------
[Tue Aug 30 12:24:01 EEST 2022][INFO] [SUB]                        24.7s (13.5% of total time) in 57 GCs | Peak RSS: 1.92GB | CPU load: 4.32
[Tue Aug 30 12:24:01 EEST 2022][INFO] [SUB] ------------------------------------------------------------------------------------------------------------------------
[Tue Aug 30 12:24:01 EEST 2022][INFO] [SUB] Produced artifacts:
[Tue Aug 30 12:24:01 EEST 2022][INFO] [SUB]  /Users/yousefhamarsheh/Desktop/demo1/target/gluonfx/aarch64-darwin/gvm/demo1/com.example.demo1.main.driver.build_artifacts.txt (txt)
[Tue Aug 30 12:24:01 EEST 2022][INFO] [SUB]  /Users/yousefhamarsheh/Desktop/demo1/target/gluonfx/aarch64-darwin/gvm/demo1/com.example.demo1.main.driver.h (header)
[Tue Aug 30 12:24:01 EEST 2022][INFO] [SUB]  /Users/yousefhamarsheh/Desktop/demo1/target/gluonfx/aarch64-darwin/gvm/demo1/com.example.demo1.main.driver_dynamic.h (header)
[Tue Aug 30 12:24:01 EEST 2022][INFO] [SUB]  /Users/yousefhamarsheh/Desktop/demo1/target/gluonfx/aarch64-darwin/gvm/demo1/graal_isolate.h (header)
[Tue Aug 30 12:24:01 EEST 2022][INFO] [SUB]  /Users/yousefhamarsheh/Desktop/demo1/target/gluonfx/aarch64-darwin/gvm/demo1/graal_isolate_dynamic.h (header)
[Tue Aug 30 12:24:01 EEST 2022][INFO] [SUB] ========================================================================================================================
[Tue Aug 30 12:24:01 EEST 2022][INFO] [SUB] Finished generating 'com.example.demo1.main.driver' in 3m 2s.
[INFO] 
[INFO] --- gluonfx-maven-plugin:1.0.15:link (default-cli) @ demo1 ---
[Tue Aug 30 12:24:01 EEST 2022][INFO] Substrate is tested with the Gluon's GraalVM build which you can find at https://github.com/gluonhq/graal/releases.
While you can still use other GraalVM builds, there is no guarantee that these will work properly with Substrate
[Tue Aug 30 12:24:01 EEST 2022][INFO] ==================== LINK TASK ====================
[Tue Aug 30 12:24:03 EEST 2022][INFO] [SUB] Undefined symbols for architecture arm64:
[Tue Aug 30 12:24:03 EEST 2022][INFO] [SUB]   "_JNI_OnLoad_jaas", referenced from:
[Tue Aug 30 12:24:03 EEST 2022][INFO] [SUB]       ___svm_vm_target_staticlibraries in com.example.demo1.main.driver.o
[Tue Aug 30 12:24:03 EEST 2022][INFO] [SUB]   "_Java_com_sun_management_internal_OperatingSystemImpl_getTotalMemorySize0", referenced from:
[Tue Aug 30 12:24:03 EEST 2022][INFO] [SUB]       ___svm_vm_target_libraries in com.example.demo1.main.driver.o
[Tue Aug 30 12:24:03 EEST 2022][INFO] [SUB]   "_Java_com_sun_management_internal_OperatingSystemImpl_initialize0", referenced from:
[Tue Aug 30 12:24:03 EEST 2022][INFO] [SUB]       ___svm_vm_target_libc in com.example.demo1.main.driver.o
[Tue Aug 30 12:24:03 EEST 2022][INFO] [SUB]   "_Java_com_sun_security_auth_module_UnixSystem_getUnixInfo", referenced from:
[Tue Aug 30 12:24:03 EEST 2022][INFO] [SUB]       ___svm_vm_target_libc in com.example.demo1.main.driver.o
[Tue Aug 30 12:24:03 EEST 2022][INFO] [SUB] ld: symbol(s) not found for architecture arm64
[Tue Aug 30 12:24:03 EEST 2022][INFO] [SUB] clang: error: linker command failed with exit code 1 (use -v to see invocation)
[Tue Aug 30 12:24:03 EEST 2022][SEVERE] Process link failed with result: 1
Check the log files under /Users/yousefhamarsheh/Desktop/demo1/target/gluonfx/aarch64-darwin/gvm/log
And please check https://docs.gluonhq.com/ for more information.
[Tue Aug 30 12:24:03 EEST 2022][INFO] Logging process [link] to file: /Users/yousefhamarsheh/Desktop/demo1/target/gluonfx/log/process-link-1661851443149.log
[Tue Aug 30 12:24:03 EEST 2022][SEVERE] Linking failed.
Check the log files under /Users/yousefhamarsheh/Desktop/demo1/target/gluonfx/aarch64-darwin/gvm/log
And please check https://docs.gluonhq.com/ for more information.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  03:09 min
[INFO] Finished at: 2022-08-30T12:24:03+03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.gluonhq:gluonfx-maven-plugin:1.0.15:link (default-cli) on project demo1: Linking failed -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  03:10 min
[INFO] Finished at: 2022-08-30T12:24:03+03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.gluonhq:gluonfx-maven-plugin:1.0.15:build (default-cli) on project demo1: Error, gluonfx:build failed -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

您有此链接错误:

[Tue Aug 30 12:24:03 EEST 2022][INFO] [SUB] Undefined symbols for architecture arm64:
[Tue Aug 30 12:24:03 EEST 2022][INFO] [SUB]   "_JNI_OnLoad_jaas", referenced from:
[Tue Aug 30 12:24:03 EEST 2022][INFO] [SUB]       ___svm_vm_target_staticlibraries in com.example.demo1.main.driver.o

如果你这样做:

$ nm target/gluonfx/aarch64-darwin/gvm/tmp/SVM-166XXXXX/com.example.demo1.main.driver.o | grep jaas
                 U _JNI_OnLoad_jaas

这意味着您的本机图像对象中确实存在未解析的符号(由于gluonfx:compile),链接时应该修复(与gluonfx:link).

您可以在日志中看到链接命令,它应该类似于:

gcc /HelloFX/target/gluonfx/aarch64-darwin/gvm/HelloFX/AppDelegate.o /HelloFX/target/gluonfx/aarch64-darwin/gvm/HelloFX/launcher.o \
/HelloFX/target/gluonfx/aarch64-darwin/gvm/tmp/SVM-1661853087924/hellofx.hellofx.o \
-ljava -lnio -lzip -lnet -lprefs -lj2pkcs11 -lfdlibm -lextnet -ljvm -llibchelper -ldarwin -lpthread -lz -ldl -lstdc++ \
-mmacosx-version-min=10.12 -lobjc -Wl,-framework,Foundation ... \
-Wl,-force_load,~/.gluon/substrate/javafxStaticSdk/19-ea+8/darwin-aarch64/sdk/lib/libglass.a ... \
-o /HelloFX/target/gluonfx/aarch64-darwin/HelloFX -L~/.gluon/substrate/javafxStaticSdk/19-ea+8/darwin-aarch64/sdk/lib \
-L/~/.gluon/substrate/graalvm/graalvm-svm-java17-darwin-m1-gluon-22.1.0.1-Final/Contents/Home/lib/svm/clibraries/darwin-aarch64 \ 
-L/~/.gluon/substrate/graalvm/graalvm-svm-java17-darwin-m1-gluon-22.1.0.1-Final/Contents/Home/lib/static/darwin-aarch64

注意添加的库:libjava.a, libnio.a, libnet.a,...

这些来自~/.gluon/substrate/graalvm/graalvm-svm-java17-darwin-m1-gluon-22.1.0.1-Final/Contents/Home/lib/static/darwin-aarch64.

但是,那libjaas.a库未链接,这解释了上述错误。

好消息是,缺少的库可以在该路径中与其他库一起使用,因此您可以轻松地将其包含在链接命令中linkerArgs https://docs.gluonhq.com/#_linkerargs:

           <plugin>
                <groupId>com.gluonhq</groupId>
                <artifactId>gluonfx-maven-plugin</artifactId>
                <version>${gluonfx.maven.plugin.version}</version>
                <configuration>
                     <target>${gluonfx.target}</target>
                     <mainClass>${main.class}</mainClass>
                     <linkerArgs>
                         <arg>-ljaas</arg>
                     </linkerArgs>
                </configuration>
            </plugin>

Now run mvn gluonfx:link再次,链接错误应该消失了。

其他一些提示:

  • 使用推荐的 GraalVM 22.1.0.1-Final 的 Gluon 版本(请参阅docs https://docs.gluonhq.com/#prerequisites_macos)
  • Run mvn gluonfx:runagent如果您还没有,在构建本机映像之前,请先发现项目中反射的所有用途。
  • 不要使用--allow-incomplete-classpath,最好预先修复错误。
  • 媒体对 GluonFX 插件的支持非常有限(基于您的依赖项)(请参阅docs https://docs.gluonhq.com/#_platforms.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

GraalVM 无​​法使用数据库连接 的相关文章

  • 在Java中将*s打印为三角形?

    我在 Java 课程中的作业是制作 3 个三角形 一份左对齐 一份右对齐 一份居中 我必须为什么类型的三角形制作一个菜单 然后输入需要多少行 三角形必须看起来像这样 到目前为止 我能够完成左对齐的三角形 但我似乎无法获得其他两个 我尝试用谷
  • 如何从 Play WSClient 的字符串创建 WSResponse 对象

    文档 https www playframework com documentation 2 4 x JavaTestingWebServiceClients Mock the web service建议使用模拟Web服务测试基于WSCli
  • 将一种类型的对象声明为另一种类型的实例有什么好处? [复制]

    这个问题在这里已经有答案了 可能的重复 Base b2 new Child 是什么意思 表示 https stackoverflow com questions 4447924 what does base b2 new child sig
  • Quarkus 不以编程方式选择 bean

    我试图以编程方式选择 bean 但 quarkus 不会注入 bean 并引发异常 不支持吗 public enum ReportType ONE TWO Qualifier Retention RUNTIME Target METHOD
  • 如何在Java中优雅地处理SIGKILL信号

    当程序收到终止信号时如何处理清理 例如 我连接到一个应用程序 希望任何第三方应用程序 我的应用程序 发送finish注销时的命令 发送该信息最好说什么finish当我的应用程序被破坏时的命令kill 9 编辑1 kill 9无法被捕获 谢谢
  • Java:线程“主”中的异常 java.lang.StringIndexOutOfBoundsException:字符串索引超出范围:

    我是初学者 谁能帮我弄清楚我们在做什么 我正在尝试读取字符串并将字符串的每个字符存储在数组中 import java util Scanner public class CoreMainDigitExtractor static Scann
  • 在 Java 中从 SOAPMessage 获取原始 XML

    我已经在 J AX WS 中设置了 SOAP WebServiceProvider 但我无法弄清楚如何从 SOAPMessage 或任何 Node 对象获取原始 XML 下面是我现在获得的代码示例 以及我试图获取 XML 的位置 WebSe
  • 如何为小程序提供对文件系统写入的访问权限

    我在设置小程序的策略文件时遇到问题 我是第一次这样做 不知道如何在java中设置小程序的策略文件 实际上我想授予小程序在文件系统上写入的权限 为此我必须向小程序授予文件权限 所以我创建了一个名为 java policy 的文件 并将以下代码
  • 具有 CRUD 功能的基于 Spring Web 的管理工具

    在 PHP Symfony 世界里有一个工具叫 Sonata Adminhttps sonata project org https sonata project org 基于 AdminLTE 模板 这是一款一体化管理工具 具有登录 菜单
  • 当 JMS Prod 位于辅助 POJO 类中时,如何在事务中包含 JMS Producer

    简短的问题 有没有办法强制无状态 EJB 调用的 POJO 存在于 EJB 的上下文中 以便事务和资源注入可以在 POJO 中工作 具体来说 在我想要做的事情的上下文中 如何在 EJB 的事务中包含 POJO JMS 生产者 该生产者在调用
  • Java 中的 ExecuteUpdate sql 语句不起作用

    我正在学习如何将 SQL 与 Java 结合使用 我已成功安装 JDBC 驱动程序 并且能够从数据库读取记录并将其打印在屏幕上 我的问题发生在尝试执行更新或插入语句时 没有任何反应 这是我的代码 问题所在的方法 public static
  • 多线程——更快的方法?

    我有一堂有吸气剂的课程getInt 和一个二传手setInt 在某个领域 比如说领域 Integer Int 一个类的一个对象 比如说SomeClass The setInt 这里是同步的 getInt isn t 我正在更新的值Int来自
  • MongoDB java 驱动程序 3.0 在身份验证时无法捕获异常

    我超级卡住o 0 在尝试通过 Java 驱动程序进行身份验证时 存在捕获异常的问题 正如你可能会看到的Throwable类不工作 private MongoClient mongoClient private MongoDatabase m
  • Java8:流映射同一流中的两个属性

    我有课Model带有以下签名 class Model private String stringA private String stringB public Model String stringA String stringB this
  • Java 中处理异步响应的设计模式

    我读过类似问答的答案 如何在 JAVA 中创建异步 HTTP 请求 https stackoverflow com questions 3142915 how do you create an asynchronous http reque
  • 从浏览器访问本地文件?

    您好 我想从浏览器访问系统的本地文件 由于涉及大量安全检查 是否可以通过某种方式实现这一目标 或使用 ActiveX 或 Java Applet 的任何其他工作环境 请帮帮我 要通过浏览器访问本地文件 您可以使用签名的 Java Apple
  • java中的预增量/后增量

    有人可以帮助我理解为什么 int i 1 int j 1 int k 1 int l 1 System out println i i System out println j j System out println k k System
  • 如何清理 Runtime.exec() 中使用的用户输入?

    我需要通过命令行调用自定义脚本 这些脚本需要很少的参数并在 Linux 机器上调用 当前版本容易出现各种shell注入 如何清理用户给出的参数 参数包括登录名和路径 Unix 或 Windows 路径 用户应该能够输入任何可能的路径 该路径
  • 如何使用注释处理 Hibernate 和 Spring 中的连接查询?

    我正在使用 Spring 和 Hibernate 以及 MySQL 开发应用程序 我是 Hibernate 新手 完成了基本任务 现在我需要在选择查询中应用联接以使用注释从多个表中获取数据 我已经搜索过但仍然没有任何想法 这是我的数据库表和
  • 使用 AmazonSNSClient 发送短信时的授权

    aws 官方文档如何发送短信 http docs aws amazon com sns latest dg sms publish to phone html使用 java 中的 aws SDK 非常简单 但是 当发送如底部示例所示的消息时

随机推荐