修改名称和URL

  1. <name>test</name>
  2. <url>http://www.ecut.edu.cn/test</url>

修改properties

  1. <properties>
  2. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  3. <!-- 根据自己的 Project SDK 来确定版本 -->
  4. <maven.compiler.source>11</maven.compiler.source>
  5. <maven.compiler.target>11</maven.compiler.target>
  6. <maven.compiler.compilerVersion>11</maven.compiler.compilerVersion>
  7. </properties>

添加依赖

  1. <dependencies>
  2. <!-- MySQL Driver -->
  3. <dependency>
  4. <groupId>mysql</groupId>
  5. <artifactId>mysql-connector-java</artifactId>
  6. <version>8.0.20</version>
  7. </dependency>
  8. <!-- Java Servlet -->
  9. <dependency>
  10. <groupId>javax.servlet</groupId>
  11. <artifactId>javax.servlet-api</artifactId>
  12. <version>4.0.1</version>
  13. <scope>provided</scope>
  14. </dependency>
  15. <!-- Apache Velocity -->
  16. <dependency>
  17. <groupId>org.apache.velocity.tools</groupId>
  18. <artifactId>velocity-tools-view</artifactId>
  19. <version>3.0</version>
  20. </dependency>
  21. </dependencies>

修改build

  1. <build>
  2. <finalName>${project.artifactId}</finalName>
  3. <plugins>
  4. <!-- Maven Resource Plugin -->
  5. <plugin>
  6. <groupId>org.apache.maven.plugins</groupId>
  7. <artifactId>maven-resources-plugin</artifactId>
  8. <version>3.1.0</version>
  9. <configuration>
  10. <encoding>${project.build.sourceEncoding}</encoding>
  11. </configuration>
  12. </plugin>
  13. <!-- Maven Compiler Plugin -->
  14. <plugin>
  15. <groupId>org.apache.maven.plugins</groupId>
  16. <artifactId>maven-compiler-plugin</artifactId>
  17. <version>3.8.0</version>
  18. <configuration>
  19. <source>${maven.compiler.source}</source>
  20. <target>${maven.compiler.target}</target>
  21. <compilerVersion>${maven.compiler.compilerVersion}</compilerVersion>
  22. <encoding>${project.build.sourceEncoding}</encoding>
  23. </configuration>
  24. </plugin>
  25. <!-- Maven Jetty Plugin -->
  26. <plugin>
  27. <groupId>org.eclipse.jetty</groupId>
  28. <artifactId>jetty-maven-plugin</artifactId>
  29. <version>9.4.30.v20200611</version>
  30. <configuration>
  31. <httpConnector>
  32. <port>8080</port>
  33. </httpConnector>
  34. <useTestClasspath>true</useTestClasspath>
  35. <webAppConfig>
  36. <!-- 这里指定在浏览器访问时,当前Web应用的根路径 -->
  37. <contextPath>/</contextPath>
  38. <!-- 默认描述符文件 jetty.xml 需要放在 工程 根目录下( 也就是跟pom.xml在同一层次) -->
  39. <defaultsDescriptor>jetty.xml</defaultsDescriptor>
  40. </webAppConfig>
  41. </configuration>
  42. </plugin>
  43. <!-- Maven Tomcat Plugin -->
  44. <plugin>
  45. <groupId>org.apache.tomcat.maven</groupId>
  46. <artifactId>tomcat7-maven-plugin</artifactId>
  47. <version>2.2</version>
  48. <configuration>
  49. <port>8080</port>
  50. <path>/</path>
  51. <uriEncoding>UTF-8</uriEncoding>
  52. <useBodyEncodingForURI>true</useBodyEncodingForURI>
  53. </configuration>
  54. </plugin>
  55. </plugins>
  56. </build>