Невозможно запустить программу "cmd": ошибка = 2, нет такого файла или каталога - PullRequest
0 голосов
/ 27 апреля 2020

Это мой java код:

import java.io.IOException;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
}

@RestController
class HelloController {
    @GetMapping("/")
    public String testJob() {
        String path="cmd /c start C:\\myfile.bat";

         try
          {
               Runtime.getRuntime().exec(path);
          } catch (IOException e) {
                return e.getMessage();
          }

        return "Done";
    }
} 

, он отлично работает, когда я его запускаю, но после развертывания в heroku я получил эту ошибку:

Cannot run program "cmd": error=2, No such file or directory

Есть предложения?

1 Ответ

0 голосов
/ 28 апреля 2020

Это мой новый код

package com.example.demo;

import local_project.addcase_0_1.addCase;


import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);

    }
}
@RestController
class HelloController {
    @GetMapping("/")
    public String TestJob() {
        addCase a = new addCase();
        a.runJob(new String[] {});   
        return "Added";
    }
}

Я пытаюсь запустить работу с календарем в коде java! Я следовал этим инструкциям https://help.talend.com/reader/Lod~TDRaNw2L2VZKV9XgZw/ty4l9kEdDoVHlHIAOW1e~Q] [1] , и он отлично работает, когда я его запускаю, но я не могу развернуть его на heroku

remote:        [INFO] 3 errors
remote:        [INFO] -------------------------------------------------------------
remote:        [INFO] ------------------------------------------------------------------------
remote:        [INFO] BUILD FAILURE
remote:        [INFO] ------------------------------------------------------------------------
remote:        [INFO] Total time:  11.171 s
remote:        [INFO] Finished at: 2020-04-28T13:19:02Z
remote:        [INFO] ------------------------------------------------------------------------
remote:        [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project demo: Compilation failure: Compilation failure:
remote:        [ERROR] /tmp/build_555cf666918f4cc22848d177306270f3/src/main/java/com/example/demo/DemoApplication.java:[2,33] package local_project.addcase_0_1 does not exist
remote:        [ERROR] /tmp/build_555cf666918f4cc22848d177306270f3/src/main/java/com/example/demo/DemoApplication.java:[22,17] cannot find symbol
remote:        [ERROR]   symbol:   class addCase
remote:        [ERROR]   location: class com.example.demo.HelloController
remote:        [ERROR] /tmp/build_555cf666918f4cc22848d177306270f3/src/main/java/com/example/demo/DemoApplication.java:[22,33] cannot find symbol
remote:        [ERROR]   symbol:   class addCase
remote:        [ERROR]   location: class com.example.demo.HelloController
remote:        [ERROR] -> [Help 1]
remote:        [ERROR]
remote:        [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
remote:        [ERROR] Re-run Maven using the -X switch to enable full debug logging.
remote:        [ERROR]
remote:        [ERROR] For more information about the errors and possible solutions, please read the following articles:
remote:        [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
remote:
remote:  !     ERROR: Failed to build app with Maven
remote:        We're sorry this build is failing! If you can't find the issue in application code,
remote:        please submit a ticket so we can help: https://help.heroku.com/
remote:
remote:  !     Push rejected, failed to compile Java app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to excel-to-case.
remote:
To https://git.heroku.com/excel-to-case.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/excel-to-case.git'
...