配置Maven
约定大于配置
file—>settings 搜索maven 更改以下三个为自己的maven配置
- 注:IDEA项目创建成功后,要看一眼Maven的配置,可能他就使用默认的
IDEA每次都要重复配置Maven 解决
- 在IDEA中的全局默认配置中去配置
点击settings后去配置Maven
粗解pom.xml
maven由于它的约定大于配置,我们之后可能遇到我们写的配置文件,无法被到处或者生效的问题,解决方案如下:
<!-- 在build中配置resources,来防止我们资源导出失败的问题 -->
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>**/*.properties</exclude>
<exclude>**/*.xml</exclude>
</excludes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</build>
标记文件夹功能(扩展了解)
配置tomcat
4.去除警告
- 为什么会有这个问题:我们访问一个网站,需要指定一个文件夹名字
5.
6.点击apply ok即可
7.启动
8.浏览器自动弹出,出现hello world!代表启动成功
Maven项目中tomcat无法配置
maven默认web项目中的web.xml版本有问题
替换为webapp4.0版本和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">
</web-app>