草庐IT

create_method

全部标签

java - 回退 : does not creates log file

首先,我尝试了所有存在的解决方案,但没有任何效果,所以我不想让任何人说这个问题是重复的。我无法使用logback登录到文件,但我可以毫无问题地登录到控制台。我的logback.xml文件内容:%-4relative[%thread]%-5level%logger{35}-%msg%ntrue/root/connector/logs/connector.log%d{yyyy-MM-ddHH:mm:ss}%-5level[%thread]\(%class{25}:%line\)-%msg%n/root/connector/logs/connector.log.%d{yyyy-MM-dd}.

java - SCJP问题: Java method overloading with var-args.是什么道理?

为什么下面的程序会抛出异常?publicclassMainClass{publicstaticvoidmain(String[]argv){callMethod(2);}publicstaticvoidcallMethod(Integer...i){System.out.println("Wrapper");}publicstaticvoidcallMethod(int...i){System.out.println("Primitive");}方法callMethod(Integer[])对于MainClass类型不明确好的,我可以看到这两种方法中的任何一种都可以工作(如果另一种被注

java - java.lang.reflect.Method 线程安全吗?

java.lang.reflect.Method线程安全吗?我的程序的性能分析结果显示Class.getMethod()在多次调用时花费了相当多的计算时间,比我预期的要多一点。我可以调用一次并将生成的方法存储在易于访问的地方。但是随后,多个Web工作线程将同时使用存储的Method对象。这样安全吗? 最佳答案 方法可以安全地跨多个线程使用,前提是您在使方法对多个线程可用后不更改方法的状态。例如您可以在两个线程中调用setAccessible(true)和setAccessible(false),结果将不是线程安全的。然而,这并没有什

java.lang.VerifyError : (class: ea/Individual, method: <init> signature: (I)V) 构造函数必须调用 super() 或 this()

我在这个类中没有发现任何错误,但Netbeans在那个类中不断显示红色符号。类是/**Tochangethistemplate,chooseTools|Templates*andopenthetemplateintheeditor.*/packageea;/****@authorriyad*/importjava.util.Random;importjava.util.BitSet;publicclassIndividual{BitSetvariable;doublex;doublefitness;doublesharedFitness;finalintSIZE;Randomgener

Java 泛型 : creating collections of class objects extending Throwable

为什么第一行可以,第二行不行?Collection>exs=newArrayList>(){{add(MyOwnException.class);}};Collection>exs=Arrays.asList(MyOwnException.class); 最佳答案 错误的原因是java推断出错误的类型,但您可以通过在调用类型化方法时指定类型来使其编译,无需强制转换Arrays.asList():Collection>exs=Arrays.>asList(Exception.class);//compiles在不指定类型的情况下,ja

java - 解释警告 : non-varargs call of varargs method with inexact argument type for last parameter

这个问题在这里已经有了答案:WhydoIgetacompilationwarninghere(varargsmethodcallinJava)(5个答案)关闭6年前。这是我收到警告的示例代码。StringlsSQL=foMetaQuery.getSQL();StringlsNewSQL=replace(lsSQL,"''{","''{");lsNewSQL=replace(lsNewSQL,"}''","}''");lsNewSQL=replace(lsNewSQL,"}","}");lsNewSQL=MessageFormat.format(lsNewSQL,foSubstituti

java - <method> 中的方法 setUserService 的参数 0 需要找不到类型为 <service> 的 bean

我已经解决了这个问题,但找不到发生了什么....尝试@ComponentScan,尝试命名我的服务,但似乎都没有用。错误:03:35:05,193WARN[org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext](ServerServiceThreadPool--81)Exceptionencounteredduringcontextinitialization-cancellingrefreshattempt:org.springframework.beans.fa

java - this.method() 指的是什么?

我有一个关于this.的问题陈述。假设我这里有这段代码(非常愚蠢和无用但传达了信息):classCalculate{intx,y;finalintg=5;//ConstructorpublicCalculate(inta,intb){x=a;y=b;}publicintsumAddG(){return(x+y+g);}//comparingmethodpublicbooleansame(Calculatein){if(this.sumAddG()==in.sumAddG()){//那么我的代码正确吗?当我使用this.SumAddG()时-我是指使用this的实例变量的方法SumAdd

java.lang.IllegalArgumentException : FormUrlEncoded can only be specified on HTTP methods with request body (e. g., @POST)

我正在尝试通过API上的GET方法从数据库中获取数据这是我的代码APIServive.InterfacepublicinterfaceAPIService{@FormUrlEncoded@GET("Event")CallviewEvent();}EventModel.JavapublicclassEventModel{@SerializedName("nama_event")Stringnama_event;@SerializedName("jenis_event")Stringjenis_event;@SerializedName("creator")Stringcreator;@S

Java 作用域 : Returning an object instantiated inside a method - Is it dangerous?

我是Java类(class)的学生,今天学习了一些有关Java的知识,这让我的齿轮转动起来。当我问老师如何以及为什么时,他不确定这种行为。谁能解释为什么以下示例有效?classExample{publicintex_val;publicExample(inta){this.ex_val=a;}publicintgetExVal(){returnthis.ex_val;}}如果我要在另一个类的方法中创建一个“Example”的实例并“返回”该对象,它可以成功地跳出它的原始范围并在随后使用。classParentObject{//InstanceVariablespublicExample