简体   繁体   中英

Could not find and load main class HomeController when deploy to Heroku?

This is my first time deploying to heroku. I trying to deploy Spring MVC with postgreSql project.

When i first deploying to heroku, it said i was missing the Procfile. then i added the Procfile with text that just like example in heroku website that looked like this

"web: java -cp target/classes:"target/dependency/*" HomeController"

There is "HomeController". Here is what inside HomeController.java

/**
 * Handles requests for the application home page.
 */
@Controller
public class HomeController {

    private static final Logger logger = LoggerFactory.getLogger(HomeController.class);

    /**
     * Simply selects the home view to render by returning its name.
     */
    @RequestMapping(value = "/", method = RequestMethod.GET)
    public String home() {

        return "home";
    }

}

which is this controller direct root of domain to my home.html. I have package just like "co.id.myproject.controller" in here i put my "HomeController.java"

and then when i running my application in heroku, it won't work. then i looked into heroku logs, with command prompt in cmd "Heroku logs", i found an error message that said

"could not find or load main class HomeController"

I already define the HomeController in Procfile. What i missed here?

You don't have a main method in there. You have to specify the class with your main method in the configuration file for Heroku. Also you have to specify the full qualified name of the class in the run command.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM