添加环境变量自己主动点,activator和sbt都加一下。然后运行 activator new 根据模板创建项目。也可以参考官网的直接写build.sbt。
123456789101112131415
R:\>activator new helloworld play-java
ACTIVATOR_HOME=E:\local\usr\share\activator-dist-1.3.12
Fetching the latest list of templates...
OK, application "helloworld" is being created using the "play-java" template.
To run "helloworld" from the command line, "cd helloworld" then:
R:\\helloworld/activator run
To run the test for "helloworld" from the command line, "cd helloworld" then:
R:\\helloworld/activator test
To run the Activator UI for "helloworld" from the command line, "cd helloworld" then:
R:\\helloworld/activator ui
创建好项目后,运行 activator run 看看效果:
12345678910111213141516
R:\helloworld>activator run
ACTIVATOR_HOME=E:\local\usr\share\activator-dist-1.3.12
[info] Loading project definition from R:\helloworld\project
[info] Updating {file:/R:/helloworld/project/}helloworld-build...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Set current project to helloworld (in build file:/R:/helloworld/)
[info] Updating {file:/R:/helloworld/}root...
[info] Resolving jline#jline;2.12.1 ...
[info] Done updating.
--- (Running the application, auto-reloading is enabled) ---
[info] p.c.s.NettyServer - Listening for HTTP on /0:0:0:0:0:0:0:0:9000
(Server started, use Ctrl+D to stop and go back to the console...)
import com.typesafe.sbteclipse.plugin.EclipsePlugin.EclipseKeys
// Compile the project before generating Eclipse files, so that generated .scala or .class files for views and routes are present
EclipseKeys.preTasks := Seq(compile in Compile)
EclipseKeys.projectFlavor := EclipseProjectFlavor.Java // Java project. Don't expect Scala IDE
EclipseKeys.createSrc := EclipseCreateSrc.Default + EclipseCreateSrc.ManagedClasses // Use .class files instead of generated .scala files for views and routes
EclipseKeys.withSource := false
EclipseKeys.withJavadoc := false
然后用 sbt eclipse 生成IDE项目所需文件:
12345678910111213141516171819202122232425
R:\helloworld>sbt
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8
[info] Loading project definition from R:\helloworld\project
[info] Updating {file:/R:/helloworld/project/}helloworld-build...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Set current project to helloworld (in build file:/R:/helloworld/)
[helloworld] $ eclipse
[info] About to create Eclipse project files for your project(s).
[info] Updating {file:/R:/helloworld/}root...
[info] Resolving jline#jline;2.12.1 ...
[info] Done updating.
[info] Compiling 6 Scala sources and 10 Java sources to R:\helloworld\target\scala-2.11\classes...
[info] Successfully created Eclipse project files for project(s):
[info] helloworld
[helloworld] $ compile
[success] Total time: 3 s, completed 2016-11-10 13:11:49
[helloworld] $ eclipse
[info] About to create Eclipse project files for your project(s).
[info] Successfully created Eclipse project files for project(s):
[info] helloworld
[helloworld] $