(1) Ändern Sie die Datei <Packages> Krieg </packaging> von pom.xml, das standardmäßig das JAR -Paket ist. Fügen Sie <Dendname> Springboot </FinalName> zum <Build> -Knoten hinzu, dh der Name des Kriegspakets wird generiert. Der vollständige Inhalt des pom.xml -Datei lautet wie folgt:
<? xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>springboot</groupId> <artifactId>springboot</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>war</packaging> <name>springboot</name> <description>Demo project for Spring Boot</description> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.4.RELEASE</version> <relativePath/> <!-- Lookup übergeordnet von Repository-> </übergeordnet> <Properties> <projekts.build.SourceCoding> UTF-8 </project.build.SourceCoding> <project.Reporting.outputCoding> utf-8 </project.Reporting.outputCoding> <java.version> </java.version> iversion> iversion> iversion> iversion> iversion> iversion> 1.7 </projava.version> </java.version> 1.7 </projava.version> </java.version> </projava.version> </java.version> </projava.version> <Java.version> </projava.version> <Java. <Depepecy> <GroupId> org.springFramework.boot </GroupId> <artifactId> Spring-Boot-Starter </artifactId> <ausschlüsse> <exklusion> <gruppe> org.springFramework <gruppe> org.springFramework.boot </GroupId> <artifactId> Spring-Boot-Starter-Web </artifactId> </abhängig> <abhängigkeit> <gruppe> org.springFramework <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-log4j</artifactId> <version>1.3.8.RELEASE</version> </abhängig> <depeopcy> <GroupID> org.springFramework <gruppeID> org.mybatis.spring.boot </gruupid> <artifactId> mybatis-pring-boot-starter </artifactId> <version> 1.1.1 </Version> </abhängig> </abhängig> <builds <artifactid> Spring-Boot-Maven-Plugin </artifactId> </plugin> </plugins> </build> </project>
(2) Ändern Sie die Projektstartklasse und erben Sie den SpringbootServletinitializer wie folgt:
Paket Springboot; import org.springframework.boot.springapplication; import org.springframework.boot.autoconfigure.springbootApplication; org.springframework.boot.web.support.springbootServletinitializer; import org.springframework.cache.annotation.enableCaching; SpringbootServletInitializer {public static void main (String [] args) {SpringApplication.run (SpringbootApplication.Class, Args); } @Override Protected SpringApplicationBuilder configure (SpringApplicationBuilder -Anwendung) {return application.sources (SpringbootApplication.Class); }}(3) Verpackung: Sie können als -> Maven installieren über Eclipse Run AS -> Maven Installation oder das Stammverzeichnis des Projekts, dh das gleiche Level -Verzeichnis wie pom.xml, eingeben, die CMD -Konsole starten und das MVN -Installationspaket wie folgt ausführen:
(4) Umgebungskonstruktion (Linux -Umgebung JDK -Installation und Tomacat -Installation (Springboot unterstützt Tomcat7 oder höher)))
JDK -Installationsreferenz: //www.vevb.com/linuxjishu/66536.html
Tomcat -Installationsreferenz: //www.vevb.com/article/95272.htm
(5) Laden Sie das verpackte Kriegspaket in das WebApp -Verzeichnis unter dem Tomcat -Verzeichnis hoch und starten Sie den Tomcat -Server.
(6) Zugriff auf Projektpfad: http: // IP -Adresse: Portnummer/Projektverpackungsname/Methode Name (Projektverpackungsname ist der Wert von <NAlname> in pom.xml)
(7) Einstellen auf tomcat automatisch auf
(1) Ändern Sie die Skriptdatei rc.local: vim /etc/rc.d/rc.local
(2) Fügen Sie rc.local hinzu: exportieren Sie Java_Home = JDK -Installationspfad, Tomcat -Installationspfad/bin/startup.sh Start
Das obige ist der gesamte Inhalt dieses Artikels. Ich hoffe, es wird für das Lernen aller hilfreich sein und ich hoffe, jeder wird Wulin.com mehr unterstützen.