我需要在 Kotlin 程序中打印当前的类路径。有哪些替代方案?
我的应用程序打包在 jar 文件中,我使用 Kotlin 1.3.61 和 OpenJDK 8。
在 Spring boot 1.5.9 应用程序中,我有@SpringBootApplication一个主类。
我也有@KopaxgroupApi注释,其中:
@Retention(RUNTIME)
@Target(TYPE)
@Import(KopaxgroupApiConfig.class)
public @interface KopaxgroupApi {
@AliasFor(annotation = Import.class, attribute = "value")
Class<?>[] value() default { KopaxgroupApiConfig.class };
}
Run Code Online (Sandbox Code Playgroud)
与KopaxgroupApiConfig.class是:
@Configuration
@ComponentScan(basePackages = { KopaxgroupApiConfig.CLASSPATH })
public class KopaxgroupApiConfig {
public static final String CLASSPATH = "com.kopaxgroup.api";
}
Run Code Online (Sandbox Code Playgroud)
我在其中创建了一个新项目,com.kopaxgroup.api.customerManagement.callMeBack并且将存储库和服务分别存储在目录repository和中service。
找不到.CallMeBackServiceImplCallMeBackRepository
我在启动时遇到以下错误:
Application failed to start due to an exception
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.kopaxgroup.api.customerManagement.callMeBack.repository.CallMeBackRepository' available: expected …Run Code Online (Sandbox Code Playgroud) 我有一个引用Jar文件的Java程序.
Jar文件与.class文件存在于同一目录中,但是当我尝试从控制台运行程序时,我得到NoClassDefFound错误:-(
或者它从Eclipse运行Ok.
为什么?
您好我在Eclipse下编写了这样的函数:
public static ArrayList<String> getMails(){
ArrayList<String> mails = new ArrayList<String>();
try{
FileInputStream fstream = new FileInputStream("mails.txt");
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
while ((strLine = br.readLine()) != null) {
mails.add(strLine.trim());
}
in.close();
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
return mails;
}
Run Code Online (Sandbox Code Playgroud)
mails.txt文件位于workspace/projectname下,我想将此项保存在workspace/projectname/bin /目录下,作为相对路径,因此每当我将workspace/projectname // bin目录复制到其他位置或计算机时,让它工作.但是,当我尝试这个时,我得到"FileNotFound"异常.我怎样才能解决这个问题 ?谢谢
我们有一个使用大量FOSS/COTS软件的Java产品.我们的许多"外部"使用相同的jar产品,但使用的是不同的版本.例如,Ant 1.6.5和Ant 1.7.0; 或多个版本的xerces.我关心的是我们的应用程序的行为可能会改变或更糟,如果我们改变类路径放在一起的顺序,史诗会失败.我们使用vbs脚本为每个产品的类路径设置环境变量,然后使用引用这些环境变量的Ant xml文件.
所以,有几个问题:
一个积极的步骤是我打算使用通配符来抓住所有的罐子.但这真的只是我最关心的进口订单问题.
注意:不要射击信使.几年前,这个系统在我到达之前就已经实施了.我只是个清理工作者.
对于Manifest中具有Main Class的可执行Jar:
当我使用java -jar myjar.jar启动它时,如何在运行时找到此jar的安装目录?
我想要做的是为Flyway开发一个命令行客户端.
该工具将安装以下文件夹结构:
INSTALLATION_PATH
|
-- bin
| |
| --start.sh (launches flyway.jar)
|
-- lib
| |
| --flyway.jar (contains Main class, loads flyway.properties)
|
-- conf
|
--flyway.properties (configuration)
Run Code Online (Sandbox Code Playgroud)
flyway.jar如何解析INSTALLATION_PATH?
在我更新到hibernate-validator 4.2.0.Final之后
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.2.0.Final</version>
<scope>runtime</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
当尝试使用mvn install使用maven构建我的应用程序时, 我收到以下错误:
package org.hibernate.validator.constraints does not exist
cannot find symbol symbol : class NotBlank
Run Code Online (Sandbox Code Playgroud)
这是我的.classpath文件:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
Run Code Online (Sandbox Code Playgroud)
虽然日食没有错误.请指教.
我在安装mvn后将weblogic.xml放在WEB-INF文件夹下时遇到问题.我的weblogic.xml文件在src/main/resources/weblogic.xml下,我希望它在安装后放在WEB-INF下.(顺便打包是"战争")
我试过这个:
<resources>
<resource>
<directory>src/main/resources</directory>
<targetPath>../resources</targetPath>
<excludes><exclude>web.xml</exclude><exclude>weblogic.xml</exclude></excludes>
</resource>
<resource>
<directory>src/main/resources/config</directory>
<targetPath>..</targetPath>
<includes><include>weblogic.xml</include></includes>
</resource>
</resources>
Run Code Online (Sandbox Code Playgroud)
它正在使用安装,但是当我想要使用eclipse:eclipse的类路径时,它会给出错误:
说明资源路径位置类型无法在输出文件夹'ResponseManager/target/WEB-INF'内嵌套输出文件夹'ResponseManager/target/WEB-INF/resources'ResponseManager构建路径构建路径问题
因为classpath中的这个conf:
<classpathentry kind="src" path="src/main/resources" output="target/WEB-INF/resources" excluding="web.xml|weblogic.xml|**/*.java"/>
<classpathentry kind="src" path="src/main/resources/config" output="target/WEB-INF" including="weblogic.xml" excluding="**/*.java"/>
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
在我的〜/ .bashrc中,我通过以下方式导出我的java CLASSPATH:
CLASSPATH=$CLASSPATH:/home/user/java/libs/apache-ant-1.9.0/lib/*:/home/user/java/MyProject/libs/*
Run Code Online (Sandbox Code Playgroud)
文件夹"/ home/user/java/MyProject/libs /"包含以下jar:
colt.jar mysql-connector-java-5.1.22-bin.jar
concurrent.jar postgresql-8.4-703.jdbc4.jar
Run Code Online (Sandbox Code Playgroud)
当我尝试编译导入部分colt.jar的项目类时,我收到一条错误消息:
/src$ javac visualization/VisualizeCorrelationMatrix.java
visualization/VisualizeCorrelationMatrix.java:16: cannot access cern.colt.matrix.impl.SparseDoubleMatrix2D
class file for cern.colt.matrix.impl.SparseDoubleMatrix2D not found
int N = cm.columns();
^
Run Code Online (Sandbox Code Playgroud)
但是,当按照以下方式编译时,它可以正常工作:
/src$ javac -cp ".:/home/user/java/MyProject/libs/*" visualization/VisualizeCorrelationMatrix.java
Run Code Online (Sandbox Code Playgroud)
我检查了CLASSPATH变量中的路径和manuel optino -cp是100%相同的.echo $ CLASSPATH也返回正确的路径.
为什么我仍然会收到此错误?
这是完整的例外:
Computeappengine exceptionRemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: Client.prog (no security manager: RMI class loader disabled)
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: Client.prog (no security manager: RMI class loader disabled)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:334)
at sun.rmi.transport.Transport$1.run(Transport.java:159)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:255)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:233)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:142)
at Engine.ComputeappEngine_Stub.executeTask(Unknown …Run Code Online (Sandbox Code Playgroud)