问题
I have the following file structure:
root-folder
--.idea
--folder1-java-console-application (module 1)
----src
------main/java/my/package/App.java
----pom.xml
--folder2-play-framework-2-ui (module 2)
----app
------controllers
--------Application.java
Application.java depends on my.package.App.java. So, I import this package like this:
Application.java:
import my.package.App;
public class Application extends Controller {
public static Result index() {
return ok(index.render("Your new application is ready."));
}
}
Also I added module 1 in dependency list of module 2.
Now, when I start Play-server, I have no any errors. But, when I open URL http://localhost:9000/
, I get the error: Compilation error - package my.package.App does not exist.
I get confused. I can compile my code, but I get trouble in runtime. I try play framework in first time in my life. So, probably I don't know some information about this.
The full start project command (from IDEA) is:
"C:\Program Files\Java\jdk1.8.0_11\bin\java" -Dfile.encoding=UTF8 -Djline.terminal=none -Dsbt.log.noformat=true -Dsbt.global.base=C:\Users\Mike\AppData\Local\Temp\sbt-global-plugin3stub -Xms512M -Xmx1024M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256M -classpath C:\Users\Mike\.IntelliJIdea14\config\plugins\Scala\launcher\sbt-launch.jar xsbt.boot.Boot run
回答1:
(a) check your Play application works without dependencies;
(b) check your Play application has module #1 in class path, when started - see play framework dependencies management;
(c) build module #1 with maven (maven guides + google will help);
(d) check your module #1 jar contains my/package/App.class file.
来源:https://stackoverflow.com/questions/32981714/compilation-error-package-does-not-exist-java