zoukankan      html  css  js  c++  java
  • springboot实现图片上传之打jar包(三)

    1在pom.xml中添加Maven的依赖,如果没有对应的依赖,运行后会报错:no main mainfest attribute,in xxx.jar

    <build>
    <plugins>
    <plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    </plugin>
    </plugins>
    </build>

    2鼠标右键点击项目,然后选择Run as下的mvn install

    3文件上传和需要制定的磁盘路径

      application.properties中添加以下配置

         web.images-path可以自定义, 路径是服务器的路径

        spring.resources.static-locations是静态资源的路径,file:${web.upload-path}是读取当前配置文件中的路径

    web.images-path=G:study_toolmaven_workspaceimages
    spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,classpath:/test/,file:${web.upload-path}

    然后将fileController中的路径改为application.properties中的web.images-path即可

    4打包成功的话,这个时候会在项目中的target目录下面生成一个xxxx-0.0.1-SNAPSHOT.jar

       可以通过GUI(反编译工具将jar反编译为class文件,方便阅读)

       或者直接改尾椎,将jar改为zip,然后双击解压

    5打开cmd,找到对应的target所在位置,运行java -jar  xxxx-0.0.1-SNAPSHOT.jar

    6本地打包,线上运行就是将这个jar包通过xfttp传到阿里云上面去,然后通过xshell运行这个jar包即可

    7可以通过阿里云oss,nginx来搭建一个简单的图片服务器

  • 相关阅读:
    【JLOI 2015】城池攻占
    【BalticOI 2004】Sequence
    罗马游戏
    《STL源码剖析》STL迭代器分类
    《Effective C++》模版与泛型编程
    《Effective C++》继承与面向对象设计
    《Effective C++》实现 章节
    [C++]const_cast,dynamic_cast,reinterpret_cast,static_cast转型
    [C++]default constructor默认构造函数
    [C++]union联合体总结
  • 原文地址:https://www.cnblogs.com/zhushilai/p/13518633.html
Copyright © 2011-2022 走看看