我一般都是用在Web应用程序春天冬眠,所以我使用DI和Maven的配置,现在我想用在台式机/ Swing应用程序休眠,不使用Maven的或弹簧,和我想知道以下几点:
请指教,谢谢.
我有一个执行jar的问题.
当我做:
mvn package
Run Code Online (Sandbox Code Playgroud)
我在目标文件夹中获取了jar,但是当我想运行它时,我在slf4j api的LoggerFactory上得到一个NoClassDefFoundError.
这是我的POM.xml:
<?xml version="1.0"?>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.6</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>org.t0tec.main.Start</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Run Code Online (Sandbox Code Playgroud)
知道配置有什么问题吗?
我试图从linux中的命令行运行一个java项目:
$ java -jar target/my-app.jar -csv test.csv
并得到了这个错误
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/cli/ParseException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2531)
at java.lang.Class.getMethod0(Class.java:2774)
at java.lang.Class.getMethod(Class.java:1663)
at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.cli.ParseException
Run Code Online (Sandbox Code Playgroud)
我正在使用maven-3,这里是我的构建maven配置:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>${project.build.sourceEncoding}</encoding>
<sourceEncoding>${project.build.sourceEncoding}</sourceEncoding>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>${appClass}</mainClass>
<classpathPrefix>lib/</classpathPrefix>
<useUniqueVersions>false</useUniqueVersions>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
而我的commons-cli依赖声明
<!-- CLI -->
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.2</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
如果我将代码和依赖项删除到我的类中,我就不会再出错了.
谢谢 !
I\xe2\x80\x99m 尝试解析java.lang.ClassNotFoundException:jade.core.migration.InterPlatformMobilityService,当我为 \xe2\x80\x9cInter\xe2\x80\x9d 平台移动性安装添加包时,该问题发生在JADE(Java 代理开发框架)中,其中有一个名为 \xe2 的 JAR \x80\x9cmigration.jar\xe2\x80\x9d 其中包含InterPlatformMobilityService类。我需要这个额外的 JAR,以便在不同的计算机之间发送代理(代码和数据)。
这是我的输出,显示了错误:
\nINFO: Service jade.core.mobility.AgentMobility initialized\nSep 03, 2021 3:38:48 PM jade.core.AgentContainerImpl initAdditionalServices\nWARNING: Exception initializing service jade.core.migration.InterPlatformMobilityService\njade.core.ServiceException: An error occurred during service activation - Caused by: jade.core.migration.InterPlatformMobilityService\n at jade.core.AgentContainerImpl.startService(AgentContainerImpl.java:1169)\n at jade.core.AgentContainerImpl.initAdditionalServices(AgentContainerImpl.java:450)\n at jade.core.AgentContainerImpl.startNode(AgentContainerImpl.java:389)\n at jade.core.AgentContainerImpl.joinPlatform(AgentContainerImpl.java:502)\n at jade.core.Runtime.createMainContainer(Runtime.java:159)\n at abc.def.hgi.Setup.start(Setup.java:47)\n at abc.def.hgi.App.main(App.java:51)\nNested Exception:\njava.lang.ClassNotFoundException: jade.core.migration.InterPlatformMobilityService\n at java.net.URLClassLoader.findClass(URLClassLoader.java:382)\n at java.lang.ClassLoader.loadClass(ClassLoader.java:418)\n at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)\n at java.lang.ClassLoader.loadClass(ClassLoader.java:351)\n at java.lang.Class.forName0(Native Method)\n at java.lang.Class.forName(Class.java:264)\n at jade.core.AgentContainerImpl.startService(AgentContainerImpl.java:1153)\n at jade.core.AgentContainerImpl.initAdditionalServices(AgentContainerImpl.java:450)\n at jade.core.AgentContainerImpl.startNode(AgentContainerImpl.java:389)\n at …Run Code Online (Sandbox Code Playgroud) 我正在尝试将构建服务器信息设置到 META-INF/MANIFEST.MF 中。当将 maven-jar-plugin 与 manifestEntries 一起使用时,它效果非常好。问题是,当我将带有 maven-assemble-plugin 的 Jar 打包到带有依赖项的单个 Jar 时(如下所示:How can I create anexecutable JAR with dependency using Maven?),我再也看不到我的清单条目了。我的猜测是,在程序集运行时,我的 MANIFEST.MF 被删除,但我找不到在清单完成后设置它的方法。
这是我的 pom.xml 构建部分的样子:
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<testSourceDirectory>src/test/java</testSourceDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2</version>
<configuration>
<archive>
<manifest>
<mainClass>ConvertorMain</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-my-jar-with-dependencies</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<finalName>${project.artifactId}</finalName>
<archive>
<manifestEntries>
<Application-Version>${app.version.major}.${app.version.minor}.0</Application-Version>
<Built-By>${user}</Built-By>
<Git-Branch>${git.branch}</Git-Branch>
<Git-Commit>${git.commit}</Git-Commit>
</manifestEntries>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
</configuration>
</plugin>
</plugins>
...
</build> …Run Code Online (Sandbox Code Playgroud) 我试图在我的 JavaFX 应用程序中使用 FontAwesomeFX 8.4,但每个字形都显示为矩形(“缺失字符”字形)。顺便说一句,这是作者的测试应用程序的样子:
有什么想法可能是错的吗?
我使用的是 Arch Linux 并使用 Intellij IDEA。
聚甲醛:
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.jensd.fx.glyphs</groupId>
<artifactId>testapps</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>de.jensd</groupId>
<artifactId>fontawesomefx</artifactId>
<version>8.4</version>
</dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)
我们有payment.jar使用Spring Framework 3.1.2开发的文件.我们需要将它用作对其新版本为Spring Framework 5.x的新项目的依赖.
问题:当payment.jar用作依赖项时,payment.jar传递依赖项会添加到项目类路径中,从而导致Spring Framework 3和Spring Framework 5发生冲突.
我试过解决方案:
没有成功,胖JAR,将Spring Framework 3添加到项目中.(我做错了什么!)
因为在其中使用spring-ibatis实现payment.jar是行不通的.Spring Framework新版本不支持ibatis.
错误:
引起:java.lang.ClassNotFoundException:org.springframework.orm.ibatis.support.SqlMapClientDaoSupport
我的要求:
我需要使用payment.jar(使用Spring Framework 3.1.2)作为对Spring Framework 5.x的新项目的依赖,而没有上面提到的问题.
我已经使用Maven来构建我的命令行应用程序.现在我要将它作为jar文件分发,我需要处理应用程序的依赖项.
我不想描述包括jar文件的所有依赖这里.
我的应用程序将运行的环境有Maven.我希望Maven运行我的jar查看META-INF/groupId/artifactId/pom.xml包内的文件,这样它就知道依赖是什么,并且可以在存储库中找到它们.
有任何想法吗 ?
我正在做一个项目,我想使用 JCommander 来解析命令行输入。但是我不知道如何将它添加到我的机器并使用它。
这是JCommander的GitHub 页面。那么如何在下载代码的 zip 文件后将其添加到我的机器中呢?
我现在没有使用任何 IDE(使用 Sublime 文本和命令行)。
这是使用 Maven 创建多模块 JavaFX 应用程序的尝试。
鉴于该项目的结构如下:
project
| pom1.xml
|_____ Word Generator (Folder)
| pom2.xml
|_____logic (folder)
| WordGenerator
|_____UI (folder)
| pom3.xml
|_____marty
| App
| PrimaryController
| SecondaryController
Run Code Online (Sandbox Code Playgroud)
按照上述方案的顺序,我们有以下 pom 文件结构:
pom1.xml
project
| pom1.xml
|_____ Word Generator (Folder)
| pom2.xml
|_____logic (folder)
| WordGenerator
|_____UI (folder)
| pom3.xml
|_____marty
| App
| PrimaryController
| SecondaryController
Run Code Online (Sandbox Code Playgroud)
pom2.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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.games.marty</groupId>
<artifactId>words</artifactId>
<packaging>pom</packaging>
<version>0.1</version>
<modules>
<module>UI</module>
<module>Word Generator</module>
</modules>
<properties>
<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target> …Run Code Online (Sandbox Code Playgroud) java ×8
maven ×6
jar ×2
javafx ×2
eclipse ×1
hibernate ×1
jcommander ×1
manifest.mf ×1
maven-2 ×1
maven-plugin ×1
multi-module ×1
slf4j ×1
spring ×1