简体   繁体   中英

Running Objects in Play 2.0 Framework

I create a Scala Play 2.0 project then add a Test object with a barebones main function.

When I run the Test object I get a ClassDefNotFoundError . This is because the Test object is apparently not being compiled into a file in any project folder.

Running the bundled Play server works fine.

Has anyone tried adding a runnable object to a Scala Play framework project and had success?

The Test object is being created in a new module, within the Play project named test-module .

**** Update ****

It seems like SBT is somehow conflicting with the 'test-module' module. Play is an SBT project so it compiles to its 'target' directory. However 'test-module' is not SBT and therefore wants to compile to the 'out' directory. Problem is the compiled files never make it to the 'out' directory, in fact they don't make it to any directory at all.

IntelliJ's template for a Play project assumes Play will be the top level directory.

When creating a module inside here, one must register it with SBT as it is not done automagically.

And make sure to follow the module->src->main->scala convention for source files, or change it in the build.sbt

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