Eclipse + Tomcat - Serve webapp directly from workspace

后端 未结 9 680
旧时难觅i
旧时难觅i 2021-02-04 10:13

What is the ideal way to configure Tomcat to serve directly from my project\'s directory inside of my workspace? (related)

I want my static web resources

9条回答
  •  走了就别回头了
    2021-02-04 10:54

    I suggest using sbt together with its web plugin.

    The key feature of sbt is the continuous integration mode: This basically means, sbt fires a command, if a file changes.

    So normal sbt commands (related with the web plugin) are

    container:start
    container:stop
    container:reload / ... container:reload

    but using it in the continuous integration mode (a command starting with ~)

    ~;container:start; container:reload /

    it will automatically reload a web application when source code or any other files have changed.

    So I just save servlets, Java sources, Scala sources whatever, and hit reload in the browser, and that really saves a lot of time.

    This is the Grails feeling, but with Java as the main programming language.

    Additional information

    • I have sbt running in a terminal (I am not aware if there is a plugin for Eclipse to start it from within Eclipse)
    • sbt can compile both Java and Scala projects out of the box.
    • The web plugin is using jetty (I am not aware if it's possible to embed tomcat as well)
    • There is no need to know Scala to configure sbt, but you should read the tutorial.
    • This solution is not tied to the IDE; so it works without an IDE as well (just from the command line).

提交回复
热议问题