CATALINA_HOME vs CATALINA_BASE :
Il ne peut y avoir qu’une seule variable d’environnement CATALINA_HOME
Pour permettre à plusieurs instances de Tomcat de s’exécuter sur la même machine, l’installation des instances du serveur est un peu particulière.
La solution consiste à utiliser la variable d’environnement CATALINA_BASE. Cette variable permet de faire référence au répertoire contenant la configuration spécifique d’une instance. Lorsqu’une seule instance de Tomcat fonctionne, la valeur de cette variable est copiée de CATALINA_HOME.
In IntelliJ IDEA the application does not turn up on Tomcat webapps
directory.
Your artifacts are in directory, for example:
${dir.to.idea.project}\YourWebApp\out\artifacts
This is default directory created by IntelliJ.
Tomcat configuration is in the different folder. I am using windows 7. So it is:
CATALINA_BASE C:\Users\User\.IntelliJIdea10\system\tomcat\YourApplicationName
Yes, you can direct CATALINA_BASE
to be in CATALINA_HOME
.
But common practice is to use an external base folder. This keeps your original Tomcat folder pristine, in original condition. Also makes housekeeping a bit easier with multiple projects that might be making use of Tomcat. Each project with its own base folder keeps their own stuff neatly segregated.
Either way, you specify the base folder when configuring IntelliJ to know about Tomcat. Look in Preferences
> Build, Execution, Deployment
> Application Servers
. Click the +
icon button to set up a new configuration of Tomcat with IntelliJ, displaying the dialog box shown next. Click the folder icon within the Tomcat base directory
field to select your pre-configured base folder.
Note in my example screen shot my own practice. I keep Tomcat at the top of my Unix/macOS home folder. I create a folder for my various projects’ base folders named apache-tomcat-base
so it abuts the Tomcat folder(s) alphabetically. I then nest a project-specific folder, using Unix-style naming to avoid problems (no SPACE characters, simple, short) — such as example_app
seen here. I might further nest version-number named folders if I am working with different versions of Tomcat, such a 9.0.14
(not usual).
CRUCIAL: IntelliJ unfortunately refuses to configure this external base folder. I was spoiled with NetBeans doing this for me automatically. But in IntelliJ, despite having paid money for the Ultimate edition to get the Application Server support feature, I must configure the base folder manually. See my Question on this issue.
- Go into the Tomcat folder, copy the
conf
folder. - Paste into the nested base folder we created.
Lastly, set up a Run/Debug Configuration
for your web app. Access the dialog box shown next by using the pop-up menu next to the Run & Debug icons in upper-right corner of IntelliJ. Notice the Application server
field, where we select the IntelliJ-Tomcat configuration we established as shown above.
Bonus Tip: Avoid using the After launch
checkbox. Nasty bug causes my web app to double-launch within Tomcat. Just switch to the web browser manually, keep a bookmark for your localhost:8080
URL.
Aucun commentaire:
Enregistrer un commentaire
to criticize, to improve