Maven uses the Tomcat8 plugin solution

preface

Originally wanted to make a simple education system from JavaWeb, through the requirements document found the need to use Tomcat8.0, the requirements document recommended using external Tomcat8.5 to start the Web project. Since you do not want to download the Tomcat package, you want to start the Web project by using the Tomcat plug-in

Problems encountered

Failed to download the Tomcat8 plug-in

I checked a lot of tutorials on Baidu, but I couldn’t solve the problem of Tomcat8 plug-in download failure.

A common tutorial on the web is to use the plugin repository download to configure the following in POM.xml

  • Plug-in warehouse
<pluginRepositories>   
	  <pluginRepository>   
		<id>alfresco-public</id>    
		<url>https://artifacts.alfresco.com/nexus/content/groups/public</url>   
	  </pluginRepository>    
	  <pluginRepository>   
		<id>alfresco-public-snapshots</id>    
		<url>https://artifacts.alfresco.com/nexus/content/groups/public-snapshots</url>    
		<snapshots>   
		  <enabled>true</enabled>    
		  <updatePolicy>daily</updatePolicy>   
		</snapshots>   
	  </pluginRepository>    
	  <pluginRepository>   
		<id>beardedgeeks-releases</id>    
		<url>http://beardedgeeks.googlecode.com/svn/repository/releases</url>   
	  </pluginRepository>   
  </pluginRepositories> 
Copy the code
  • Tomcat8 plug-in
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.0</version>
    <configuration>
        <source>1.8</source>
        <target>1.8</target>
        <encoding>UTF-8</encoding>
    </configuration>
</plugin>
<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat8-maven-plugin</artifactId>
    <version>3.0-r1655215</version>
    <configuration>
        <port>8081</port>
        <path>/Edu</path>
        <uriEncoding>${project.build.sourceEncoding}</uriEncoding>
    </configuration>
</plugin>
Copy the code

Solution

Through browsing various websites, we found the link update of Ali Cloud warehouse, which required us to configure and update maven’s configuration file

<mirror>
    <id>aliyuncentral</id>
    <name>aliyun central</name>
    <url>https://maven.aliyun.com/repository/central/</url>
    <mirrorOf>central</mirrorOf>
</mirror>
<mirror>
    <id>aliyunpublic</id>
    <mirrorOf>public</mirrorOf>
    <name>aliyun public</name>
    <url>https://maven.aliyun.com/repository/public/</url>
</mirror>
<mirror>
    <id>aliyungoogle</id>
    <mirrorOf>google</mirrorOf>
    <name>aliyung oogle</name>
    <url>https://maven.aliyun.com/repository/google/</url>
</mirror>

<mirror>
    <id>aliyunspring</id>
    <mirrorOf>spring</mirrorOf>
    <name>aliyung spring</name>
    <url>https://maven.aliyun.com/repository/spring/</url>
</mirror>

<mirror>
    <id>aliyunspringplugin</id>
    <mirrorOf>spring-plugin</mirrorOf>
    <name>aliyung spring-plugin</name>
    <url>https://maven.aliyun.com/repository/spring-plugin/</url>
</mirror>
Copy the code

Then reload Maven and delete the plugin repository to download Tomcat8 again.

For more configuration of Ali Cloud warehouse, please see the official website of Ali Cloud Warehouse. Aliyun Warehouse

Tomcat8 run

Start the Web project by setting up the Tomcat8 configuration as shown below

At this point, maven’s problems with the Tomcat8 plugin are solved.