简体   繁体   English

使用 maven 多模块、spring boot 和 IntelliJ

[英]Using maven multi module, spring boot and IntelliJ

I am setting the project with spring boot + maven multi module + Intellij我正在用 spring boot + maven 多模块 + Intellij 设置项目

The structure of project is项目的结构是

Parent module
            - src
                - main
                    - java
                    - resources
                    - webapp
            - Web module
                - src
                    - main
                        - java
                        - resources
                        - webapp
                pom.xml(web)
            pom.xml(parent)

As you see on the structure the web module is under the parent module, it has problem when I use on jsp (it's fine with template from spring boot ex thymeleaf).正如你在结构上看到的 web 模块在父模块下,当我在 jsp 上使用时它有问题(使用 spring boot ex thymeleaf 的模板没问题)。

For example, add jsp at web module src > webapp > WEB-INF (of course I have done with basic setting of spring boot to use jsp) and operate web moudle application then call from controller.例如,在web模块src>webapp>WEB-INF添加jsp(当然我已经完成了spring boot的基本设置以使用jsp)并运行web模块应用程序然后从控制器调用。 There was no problem at eclipse IDE but Intellij IDE can't find jsp. eclipse IDE 没有问题,但是Intellij IDE 找不到jsp。

For the test result, it post to be find from web moudle but it find from parent module.对于测试结果,它是从 web 模块中找到的,但它是从父模块中找到的。

So modify Configuration - Enviroment - Working directory to $MODULE_WORKING_DIR$ to fix the problem (web module configuration at boot dashboard)所以修改 Configuration - Enviroment - Working directory 到 $MODULE_WORKING_DIR$ 来解决这个问题(在启动仪表板的 web 模块配置)

I want to know exact cause.我想知道确切的原因。

You need move WEB-INF to : resources.META-INF.resources.WEB-INF您需要将 WEB-INF 移动到:resources.META-INF.resources.WEB-INF

of course you need create META-INF and resources (directory) in your resources当然你需要在你的资源中创建 META-INF 和资源(目录)

If you have multiple modules (At intellij), Run> Edit configuration> Select springboot your application > Configuration tab> Working directory -> $MODULE_WORKING_DIR$如果您有多个模块(在 intellij),请运行 > 编辑配置 > 选择 springboot 您的应用程序 > 配置选项卡 > 工作目录 -> $MODULE_WORKING_DIR$

Also make sure pom.xml还要确保 pom.xml

  • include tomcat, jasper embeded dependency包括 tomcat、jasper 嵌入依赖
  • make packaging war打包装大战

Also, add springboot devtools that will help your jsp page edit without restart.此外,添加 springboot devtools 将帮助您的 jsp 页面编辑而无需重新启动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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