原创

OneBlog打jar包及jar包部署

  1. 先在码云下载OneBlog的源码,源码地址
  2. 解压源码,导入IDEA工具。找到docs-->db里的sql文件导入数据
  3. 修改数据库配置,找到blog-web和blog-admin的启动类启动,分别访问web页面localhost:8443和后台管理页面localhost:8085
  4. 没有问题,接下来打包;执行maven命令的clean,执行成功后执行install命令,OK这个时候会遇到执行install失败,报错,报错信息如下
    [INFO] blog ............................................... SUCCESS [  0.215 s]
    [INFO] blog-core .......................................... SUCCESS [  4.550 s]
    [INFO] blog-web ........................................... FAILURE [ 12.997 s]
    [INFO] blog-admin ......................................... SKIPPED
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 18.330 s
    [INFO] Finished at: 2018-11-29T09:12:45+08:00
    [INFO] Final Memory: 32M/348M
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.21.0:test (default-test) on project blog-web: There are test failures.
    [ERROR] 
    [ERROR] Please refer to D:\tools\workspace1\DBlog\blog-web\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
    [ERROR] 
    [ERROR] After correcting the problems, you can resume the build with the command
    [ERROR]   mvn <goals> -rf :blog-web
    
    这个报错是缺少maven-surefire-plugin依赖,这个依赖是用来跳过单元测试
    解决办法,在父类的POM文件中加入此依赖,如下
    <!-- 跳过单元测试 -->
       <plugins>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-surefire-plugin</artifactId>
                 <configuration>
                     <skipTests>true</skipTests>
                 </configuration>
             </plugin>
         </plugins>
    
    OK,问题解决,打包成功!包target目录中的jar包拷贝出来,运行Java -jar xxx.jar 启动服务;这种启动方式当你关闭客户端连接或者退出后服务也就停止了。
    想要后台启动,请使用后台启动命令nohup java -jar XXXXX.jar &
    如还有其他问题可参考,张亚东的博客,及码云问题总结文档
正文到此结束
本文目录