【发布时间】:2018-08-14 12:08:21
【问题描述】:
您好,我正在尝试从主类中读取文件作为参数,并在 Spring Boot 中访问另一个类中的参数。 主类是这样的
public class DemorestApplication extends SpringBootServletInitializer {
public static void main(String[] args) throws IOException {
new DemorestApplication().configure(new SpringApplicationBuilder(DemorestApplication.class)).run(args);
new UsersResources(args[0]);
}
}
我正在将一个参数传递给另一个名为 UsersResources 构造函数的类
@Path("/sample")
public class UsersResources {
private String value;
UsersResources(String value){
this.value=value;
}
//new code
@GET
@Path("Data/file/{path}")
@Produces("application/json")
public Map<String, Map<String, List<Map<String, Map<String, String>>>>> getApplicationName1(@PathParam("path") String path) throws IOException {
ReadExceldy prop = new ReadExceldy();
FileInputStream Fs = new FileInputStream(System.getProperty("user.dir")+"\\"+value);
Properties properties = new Properties();
properties.load(Fs);
String Loc=properties.getProperty("filepath");
String Na=path;
String filename=Loc+Na;
return prop.fileToJson(filename);
}
}
我正在尝试运行此代码,但它抛出一个错误提示
java.lang.NoSuchMethodException:在 com.springsampleapplication.UsersResources 类中找不到合适的构造函数 在 org.glassfish.jersey.internal.inject.JerseyClassAnalyzer.getConstructor(JerseyClassAnalyzer.java:192) ~[jersey-common-2.25.1.jar:na]
【问题讨论】:
-
无法与那个问题联系起来。
标签: java spring-boot constructor jersey command-line-arguments