如何在Windows Server 2012 R2上部署Spring Boot应用程序?
我有一个或多或少已经完成的Springboot应用程序,并且可以在本地主机上顺利运行.
I have a Springboot application that I've more or less completed and is running smoothly on my local host.
我还有一个现在可以开始使用的Windows服务器.我发现,当我用浏览器的IP地址访问该服务器时,它会在以下位置显示Windows IIS的"Hello World"页面:
I also have a Windows server that I can now begin to play with. I've figured out that when I hit this server with its IP address in my browser it shows a Hello World page from Windows IIS at this location:
C:\inetpub\wwwroot\iisstart.html
我可以简单地将当前springboot应用程序的全部内容复制并粘贴到此文件夹中,并期望它能正常工作吗?我可以复制和粘贴JAR文件吗?关于如何将应用程序部署到服务器,以便其他用户可以访问它,我一直找不到明确的答案.我该怎么办?
Can I simply copy and paste the entire contents of my current springboot application into this folder and expect it to work? Can I copy and paste a JAR file? I have been unable to find a clear answer as to how to deploy my application to my server so that other users can access it. What should I do?
Spring Boot首先使用以下插件配置使用Maven创建一个完全可执行"的jar:
Spring Boot first create a ‘fully executable’ jar with Maven use the following plugin configuration:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
</plugin>
使用Gradle
springBoot {
executable = true
}
转到应用程序目录(您必须在系统中安装Web应用程序的位置)
Go to application directory (Where you have to install web app in system )
粘贴Spring boot捆绑jar(使用 mvn软件包
构建)
Paste Spring boot bundled jar (build using mvn package
)
通过命令提示符转到当前路径,然后键入 java -jar ... jarName.jar
.(例如java -jar custstomerService.jar)
Go to current path via command prompt and just type java -jar ...jarName.jar
.(eg. java -jar custstomerService.jar)
注意:
运行完全可执行的jar时,它将jar的目录用作工作目录.
When a fully executable jar is run, it uses the jar’s directory as the working directory.
这仅适用于带有捆绑的Web服务器jar部署的春季启动,不适用于战争
This is only for spring boot with bundled web server jar deployment not for war