Check webui module
Pay attention to the red box part. For normal web projects, the folder style should be as follows:
Note that the webapp folder has a small blue dot. Only in this way can this module be considered as a web module by idea. Since our project is not a web project, we need to start a wool, so we need to make the small blue dot first.
Turn module into web project
Select the webui module and press F4 to open the settings dialog box and select modules.
click(select the webui module, and then click the plus sign) and select web
Set the path of the red font in the following figure. Set 1, then 2
clickObserve the path of the pop-up window
webui\web\WEB-INF\web.xmlThis path does not exist in the webui module at all, so at this time, you need to modify the path to point to the correct location, and select the correct deployment descriptor version. Use 2.5 here.
clickSet the path in the pop-up window.
Find the folder where the webui module is located, find the webapp folder, find web.xml (be sure to find web.xml), select it, click OK, and then set it as shown in the figure
Set the path marked in red 2. The operation mode is the same as that of 1. Note that the selected path is to the webapp folder, as shown in the following figure
At this time, if you look at the webapp folder, a small blue dot will appear
Set up artifacts
The small blue dot already exists, but at this time, the project still cannot run in Tomcat. You need to configure artifacts and put them in Tomcat (so it may not be standard. In fact, idea uses virtual tmocat instead of putting the war package into the webapp folder configured as Tomcat) to run. Select the webui module, press F4, and select artifacts
Click, and then operate as shown in the figure
Adjust the red box Department path to point to the output path in the webui module. Here we use
xxx\webui\target\, which is the output path of the webui module. You can also specify the module name, such as
xxx\webui\target\modulesNameIn general, you do not need to specify it, because it will default to the above name, namely XXX: War expanded.Click OK
Configure Tomcat artifact
How to configure Tomcat in idea is not shown here. The default is that Tomcat has been configured. Open the configured Tomcat and clickSelect artifact
An error will be reported during startup. The exception is
java.lang.ClassNotFoundException: Cannot find class：com.xxx.xxx.A。 Since webui is finally a published war package, other modules will be relied on in this war package, so the dependent modules should be set in the artifacts configuration.
Note classes. Add the dependencies of other modules to classes.
Expand the right module
Double click each module
compile outputIn other words, add the compiled output path of each module to the classes of the webui module
, click OK, and then try to start Tomcat. Normally, it should be started successfully. If the startup is not successful, clean the project, and then start it.