链接
1 2
| #后台启动jar包 nohup java -jar jar包文件名字 --server.port=启动端口号 > log.file 2>&1 &
|
Docker安装软件
VMWare
https://blog.csdn.net/u012268339/article/details/61204801
https://blog.csdn.net/m0_37781149/article/details/109472575
获取项目路径
https://blog.csdn.net/yswKnight/article/details/103695679
Spring Boot项目打包成war包
再pom文件中加上如下代码
1 2 3 4 5
| <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope> </dependency>
|
再pom文件中修改打包方式
1
| <packaging>war</packaging>
|
修改启动类
1 2 3 4 5 6 7 8 9 10 11
| @SpringBootApplication public class AliOssApplication extends SpringBootServletInitializer { public static void main(String[] args) { SpringApplication.run(AliOssApplication.class, args); }
@Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(AliOssApplication.class); } }
|
SpringBoot文件上传
yml配置文件
1 2 3 4 5 6 7
| spring: web: resources: static-locations: classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,file:${web.upload-path} web: upload-path: D:/测试/
|
Java文件上传
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| @Value("${web.upload-path}") private String uploadPath;
@Resource private HttpServletRequest request;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd/");
public String upload(MultipartFile file) throws IOException, UploadException {
String format = sdf.format(new Date()); File folder = new File(uploadPath + format); if (!folder.isDirectory()) { folder.mkdirs(); }
String oldName = file.getOriginalFilename(); String newName = UUID.randomUUID().toString() + oldName.substring(oldName.lastIndexOf("."), oldName.length()); try { file.transferTo(new File(folder, newName));
String filePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + "/" + format + newName; return filePath; } catch (IOException e) { throw new UploadException("文件上传异常"); } }
|
SpringBoot执行策略