spring boot 项目部署
1.环境准备
ide:eclipse
jdk:1.8
2.部署步骤
1.右键项目名称->run as ->7,maven build-> 使用clean package 命令进行打包
2.这个过程中可能会出现下边这种错误,在pom文件中添加build 里边的片段就好
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.463 s <<< FAILURE! - in com.example.demo.SinosoftApplicationTests
[ERROR] initializationError(com.example.demo.SinosoftApplicationTests) Time elapsed: 0.006 s <<< ERROR!
java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test
[INFO]
[INFO] Results:
[INFO]
[ERROR] Errors:
[ERROR] SinosoftApplicationTests.initializationError » IllegalState Unable to find a @...
[INFO]
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.067 s
[INFO] Finished at: 2018-07-11T14:28:56+08:00
[INFO] Final Memory: 35M/327M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.21.0:test (default-test) on project dh_app: There are test failures.
[ERROR]
[ERROR] Please refer to H:\project\zz\dh_app\target\surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
3.打包完成后将target下的war复制到服务器任意路径,并通过cmd 的方式进入该文件夹,使用java -jar —-.war命令运行该程序即可
4.输入地址访问
5.需要注意的是排除tomcat需要去掉
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<!-- <exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions> -->
</dependency>
==============================================================================================================================================================================
这只是一种方式,第二种方式:我在使用tomcat部署时 发现程序可以运行,但是页面无法访问的情况,希望大神指点。