How to convert a web application project to a maven project?

I have a dynamic web project exsting. Now I plan to participate in this project. Can I find out how I can achieve this?

+4
source share
3 answers

First of all, it’s not good to change the type of web project once you have created its bad practice. You must decide before starting your project to do this as a dynamic web project or with maven. When you do this, this will help to avoid many errors when converting a project type to another, as well as when using the IDE to create, for example, a Maven project, it will automatically create a database based on your project configurations.

- Maven. :

Eclipse, , → Maven. , , :

  • Maven

    • java \src\main\java
    • web.xml \src\main\webapp\WEB-INF
    • pom.xml . ( - , )
  • pom.xml. pom.xml, .

  • . , , -, pom.xml.

  • mvn compile. , . Windows, , Linux, Terminal.

  • () , Eclipse IDE, mvn eclipse:eclipse -Dwtpversion=2.0.

  • .war . /Terminal maven mvn war:war. WAR .

+4

- Java - Maven. , Maven :

Folder structure – Follow this Maven’s folder structure.
Dependency library – Put all your dependency libraries in pom.xml file.
+1

. , / -, , .

maven - maven-archetype-webapp archetype . , maven:

mvn archetype:generate -DarchetypeArtifactId=maven-archetype-webapp

Startup mvn packagewill create your project and pack it into a WAR file. Copy the Java code into src/main/java(create a directory if it is missing), which will be compiled and placed in WEB-INF/classes/the resulting WAR file. Files placed in src/main/webappare directly copied to the root directory of WAR.

See this tutorial for an example using Tomcat and Spring .

0
source

Source: https://habr.com/ru/post/1543541/


All Articles