Forum Stats

  • 3,838,473 Users
  • 2,262,371 Discussions
  • 7,900,664 Comments

Discussions

error in java

Tony007
Tony007 Member Posts: 4,248 Bronze Trophy
edited Oct 15, 2019 5:25AM in Java Programming

hi am geting this error in my application

C:\Spring5\spring-reciept-app>mvn compile[INFO] Scanning for projects...[INFO][INFO] -------------------< com.reciept:spring-reciept-app >-------------------[INFO] Building spring-reciept-app 0.0.1-SNAPSHOT[INFO] --------------------------------[ jar ]---------------------------------[INFO][INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ spring-reciept-app ---[INFO] Using 'UTF-8' encoding to copy filtered resources.[INFO] Copying 1 resource[INFO] Copying 1 resource[INFO][INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ spring-reciept-app ---[INFO] Changes detected - recompiling the module![INFO] Compiling 8 source files to C:\Spring5\spring-reciept-app\target\classes[INFO] Some messages have been simplified; recompile with -Xdiags:verbose to get full output[INFO] -------------------------------------------------------------[ERROR] COMPILATION ERROR :[INFO] -------------------------------------------------------------[ERROR] /C:/Spring5/spring-reciept-app/src/main/java/com/reciept/springrecieptapp/TasksApplication.java:[24,31] constructor Task in class org.springframework.scheduling.config.Task cannot be applied to given types;  required: java.lang.Runnable  found: long,java.lang.String,java.time.LocalDate,boolean  reason: actual and formal argument lists differ in length[ERROR] /C:/Spring5/spring-reciept-app/src/main/java/com/reciept/springrecieptapp/TasksApplication.java:[25,31] constructor Task in class org.springframework.scheduling.config.Task cannot be applied to given types;  required: java.lang.Runnable  found: long,java.lang.String,java.time.LocalDate,boolean  reason: actual and formal argument lists differ in length[ERROR] /C:/Spring5/spring-reciept-app/src/main/java/com/reciept/springrecieptapp/TasksApplication.java:[26,31] constructor Task in class org.springframework.scheduling.config.Task cannot be applied to given types;  required: java.lang.Runnable  found: long,java.lang.String,java.time.LocalDate,boolean  reason: actual and formal argument lists differ in length[ERROR] /C:/Spring5/spring-reciept-app/src/main/java/com/reciept/springrecieptapp/TasksApplication.java:[27,31] constructor Task in class org.springframework.scheduling.config.Task cannot be applied to given types;  required: java.lang.Runnable  found: long,java.lang.String,java.time.LocalDate,boolean  reason: actual and formal argument lists differ in length[ERROR] /C:/Spring5/spring-reciept-app/src/main/java/com/reciept/springrecieptapp/TasksApplication.java:[28,31] constructor Task in class org.springframework.scheduling.config.Task cannot be applied to given types;  required: java.lang.Runnable  found: long,java.lang.String,java.time.LocalDate,boolean  reason: actual and formal argument lists differ in length[ERROR] /C:/Spring5/spring-reciept-app/src/main/java/com/reciept/springrecieptapp/TasksApplication.java:[29,31] constructor Task in class org.springframework.scheduling.config.Task cannot be applied to given types;  required: java.lang.Runnable  found: long,java.lang.String,java.time.LocalDate,boolean  reason: actual and formal argument lists differ in length[ERROR] /C:/Spring5/spring-reciept-app/src/main/java/com/reciept/springrecieptapp/TasksApplication.java:[30,31] constructor Task in class org.springframework.scheduling.config.Task cannot be applied to given types;  required: java.lang.Runnable  found: long,java.lang.String,java.time.LocalDate,boolean  reason: actual and formal argument lists differ in length[ERROR] /C:/Spring5/spring-reciept-app/src/main/java/com/reciept/springrecieptapp/TasksApplication.java:[31,31] constructor Task in class org.springframework.scheduling.config.Task cannot be applied to given types;  required: java.lang.Runnable  found: long,java.lang.String,java.time.LocalDate,boolean  reason: actual and formal argument lists differ in length[ERROR] /C:/Spring5/spring-reciept-app/src/main/java/com/reciept/springrecieptapp/Controller/TaskController.java:[21,37] incompatible types: java.lang.Iterable<org.springframework.scheduling.config.Task> cannot be converted to java.lang.Iterable<javafx.concurrent.Task>[ERROR] /C:/Spring5/spring-reciept-app/src/main/java/com/reciept/springrecieptapp/Controller/TaskController.java:[26,38] incompatible types: javafx.concurrent.Task cannot be converted to org.springframework.scheduling.config.Task[INFO] 10 errors[INFO] -------------------------------------------------------------[INFO] ------------------------------------------------------------------------[INFO] BUILD FAILURE[INFO] ------------------------------------------------------------------------[INFO] Total time:  11.558 s[INFO] Finished at: 2019-09-13T18:18:54+02:00[INFO] ------------------------------------------------------------------------[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project spring-reciept-app: Compilation failure: Compilation failure:[ERROR] /C:/Spring5/spring-reciept-app/src/main/java/com/reciept/springrecieptapp/TasksApplication.java:[24,31] constructor Task in class org.springframework.scheduling.config.Task cannot be applied to given types;[ERROR]   required: java.lang.Runnable[ERROR]   found: long,java.lang.String,java.time.LocalDate,boolean[ERROR]   reason: actual and formal argument lists differ in length[ERROR] /C:/Spring5/spring-reciept-app/src/main/java/com/reciept/springrecieptapp/TasksApplication.java:[25,31] constructor Task in class org.springframework.scheduling.config.Task cannot be applied to given types;[ERROR]   required: java.lang.Runnable[ERROR]   found: long,java.lang.String,java.time.LocalDate,boolean[ERROR]   reason: actual and formal argument lists differ in length[ERROR] /C:/Spring5/spring-reciept-app/src/main/java/com/reciept/springrecieptapp/TasksApplication.java:[26,31] constructor Task in class org.springframework.scheduling.config.Task cannot be applied to given types;[ERROR]   required: java.lang.Runnable[ERROR]   found: long,java.lang.String,java.time.LocalDate,boolean[ERROR]   reason: actual and formal argument lists differ in length[ERROR] /C:/Spring5/spring-reciept-app/src/main/java/com/reciept/springrecieptapp/TasksApplication.java:[27,31] constructor Task in class org.springframework.scheduling.config.Task cannot be applied to given types;[ERROR]   required: java.lang.Runnable[ERROR]   found: long,java.lang.String,java.time.LocalDate,boolean[ERROR]   reason: actual and formal argument lists differ in length[ERROR] /C:/Spring5/spring-reciept-app/src/main/java/com/reciept/springrecieptapp/TasksApplication.java:[28,31] constructor Task in class org.springframework.scheduling.config.Task cannot be applied to given types;[ERROR]   required: java.lang.Runnable[ERROR]   found: long,java.lang.String,java.time.LocalDate,boolean[ERROR]   reason: actual and formal argument lists differ in length[ERROR] /C:/Spring5/spring-reciept-app/src/main/java/com/reciept/springrecieptapp/TasksApplication.java:[29,31] constructor Task in class org.springframework.scheduling.config.Task cannot be applied to given types;[ERROR]   required: java.lang.Runnable[ERROR]   found: long,java.lang.String,java.time.LocalDate,boolean[ERROR]   reason: actual and formal argument lists differ in length[ERROR] /C:/Spring5/spring-reciept-app/src/main/java/com/reciept/springrecieptapp/TasksApplication.java:[30,31] constructor Task in class org.springframework.scheduling.config.Task cannot be applied to given types;[ERROR]   required: java.lang.Runnable[ERROR]   found: long,java.lang.String,java.time.LocalDate,boolean[ERROR]   reason: actual and formal argument lists differ in length[ERROR] /C:/Spring5/spring-reciept-app/src/main/java/com/reciept/springrecieptapp/TasksApplication.java:[31,31] constructor Task in class org.springframework.scheduling.config.Task cannot be applied to given types;[ERROR]   required: java.lang.Runnable[ERROR]   found: long,java.lang.String,java.time.LocalDate,boolean[ERROR]   reason: actual and formal argument lists differ in length[ERROR] /C:/Spring5/spring-reciept-app/src/main/java/com/reciept/springrecieptapp/Controller/TaskController.java:[21,37] incompatible types: java.lang.Iterable<org.springframework.scheduling.config.Task> cannot be converted to java.lang.Iterable<javafx.concurrent.Task>[ERROR] /C:/Spring5/spring-reciept-app/src/main/java/com/reciept/springrecieptapp/Controller/TaskController.java:[26,38] incompatible types: javafx.concurrent.Task cannot be converted to org.springframework.scheduling.config.Task[ERROR] -> [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/MojoFailureException

this my code

package com.reciept.springrecieptapp;

import com.reciept.springrecieptapp.services.TaskService;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.config.Task;

import java.time.LocalDate;
import java.time.temporal.ChronoUnit;

@SpringBootApplication
public class TasksApplication {   public static void main(String[] args) {  SpringApplication.run(TasksApplication.class, args);
   }   @Bean
   CommandLineRunner runner(TaskService taskService) {   return args -> {taskService.save( new Task(1L,"Create Spring Boot Application", LocalDate.now(), true) );
   taskService.save( new Task(2L,"Create Spring Project Packages", LocalDate.now().plus(1, ChronoUnit.DAYS), false) );
   taskService.save( new Task(3L,"Create the Task Domain Class", LocalDate.now().plus(3,ChronoUnit.DAYS), false) );
   taskService.save( new Task(4L,"Create service and repository classes", LocalDate.now().plus(5,ChronoUnit.DAYS), false) );
   taskService.save( new Task(5L,"Create the command line runner to load data", LocalDate.now().plus(8, ChronoUnit.DAYS), false) );
   taskService.save( new Task(6L,"Create the required configuration properties", LocalDate.now().plus(10,ChronoUnit.DAYS), false) );
   taskService.save( new Task(7L,"Run the Spring Boot Application", LocalDate.now().plus(12,ChronoUnit.DAYS), false) );
   taskService.save( new Task(8L,"Check the H2 Console for the initial data", LocalDate.now().plus(13,ChronoUnit.DAYS), false) );
   };


   }

}

Answers

  • jwenting
    jwenting Member Posts: 4,864 Gold Badge
    edited Sep 26, 2019 2:34AM

    The error log tells you exactly what you're doing wrong, just read it.

    It says your code is wrong, you're providing the wrong argument types to the constructor for Task. It even tells you what you should be using.

  • EJP
    EJP Member Posts: 32,920 Gold Crown
    edited Oct 15, 2019 5:25AM

    This is not an 'error in Java'. It is a compilation error in your code. Check the specifcation of the method you're trying to call.