1.部署tomcat
首先需要在tomcat的tomcat-users配置文件中引入manager相应的权限
<role rolename="manager"/> <role rolename="admin"/> <role rolename="manager-gui"/> <user username = "tomcat" password = "tomcat" roles = "admin,manager,manager-gui,manager-script,manager-jmx,manager-status" />
在pom.xml的build中添加tomcat插件
<pluginManagement> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>tomcat-maven-plugin</artifactId> <version>1.1</version> <configuration> <url>http://localhost:8080/manager/text</url> <!-- <server>tomcat</server> --> <ignorePackaging>true</ignorePackaging> <username>tomcat</username> <password>tomcat</password> </configuration> </plugin> </plugins> </pluginManagement>
其中之所以在tomcat的tomcat-users配置文件中引入manager相应的权限,是因为maven要帮助我们部署项目到tomcat,所以需要配置权限
2.在src/main/java中的文件夹中书写配置文件配有部署到war(tomcat中)
在pom.xml的build中添加resource配置
<resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.xml</include> </includes> <filtering>true</filtering> </resource> </resources>
3.关于pom.xml中properties中编码的配置
<properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.encoding>UTF-8</maven.compiler.encoding> </properties>
时间: 2024-10-06 00:31:25