创建一个maven模版项目
-
1
图片.png
-
2
图片.png
-
3
图片.png
-
创建成功
图片.png
-
遇见的错误
出现No archetype found in remote catalog. Defaulting to internal catalog
错误解决方法
- 将archetype_catalog.xml文件放到本地仓库的根目录下
cd /usr/local/Cellar/maven/3.6.3_1/repository
wget https://repo1.maven.org/maven2/archetype-catalog.xml
- 在idea中改变设置
-DarchetypeCatalog=local
图片.png

- 补充创建


- 5.替换web.xml为最新,和tomcat默认一致
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0"
metadata-complete="true">
<display-name>Welcome to Tomcat</display-name>
<description>
Welcome to Tomcat
</description>
</web-app>
创建一个普通的maven模版
创建过程和之前不同之处


配置Tomcat


解决警告问题:




为什么要解决警告问题:访问一个网站,必须要指定要访问的文件夹。
启动访问http://localhost:8080/zzqsmile/
访问的就是index.jsp

maven仓库
在maven项目中配置文件资源导出问题
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</build>
pom
- 父pom.xml
<modules>
<module>servlet-01</module>
</modules>
- 子pom.xml
<parent>
<artifactId>javaweb-001-servlet</artifactId>
<groupId>com.zzqsmile</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>servlet-01</artifactId>
<packaging>war</packaging>
网友评论