windows运维

目录

nginx

1.nginx重启

nginx -s reload

2.nginx不转发http header问题解决

默认的情况下nginx引用header变量时不能使用带下划线的变量

  1. 开启非nginx标准的用户自定义header,需要在http或者server下开启header的下划线支持:
underscores_in_headers on;

Jar

1.运行jar

  1. 直接运行,关闭cmd黑窗口停止运行

    1. -Dfile.encoding=utf-8 程序返回数据出现乱码

      没卵用

      java -Dfile.encoding=utf-8 -jar xxx-0.0.1-SNAPSHOT.jar &
      
    2. –server.port=8080 动态修改端口

      java -jar demo.jar --server.port=8080
      
    3. 当我们存在多个配置文件动态指定使用某一个

      java -jar xxx.jar --spring.profiles.active=dev
      
    4. dos窗口输出的日志中出现乱码

      1.cmd命令行窗口字符编码切换为UTF-8,命令行中执行:chcp 65001

      2.修改cmd窗口字体属性,在命令行标题栏上点击右键,选择”属性”->”字体”,将字体修改为”Lucida Console”,点击确定后生效。

      chcp 65001
      cmd窗口字符编码切换回中文:chcp 936
      
  2. 编辑 .bat文件

    @echo off
    d:
    cd /ydd/marry
    start javaw -jar xxx-0.0.1-SNAPSHOT.jar
    

2.查看哪些jar包在启动

运行jdk/bin下的jconsole.exe


查看某个端口号被占用情况

  1. 查看3798端口是否被占用,以及占用端口的进程PID

    netstat -ano |findstr 3798
    
  2. 查看pid为2452的是什么程序在用

    tasklist |findstr 2452
    
  3. 结束PID为2452的进程及子进程

    taskkill /T /F /PID 2452
    

    强制 (/F参数)

    杀死pid为2452的所有进程包括子进程 (/T参数)

4.将Springboot项目瘦身,简化部署

解决办法

  1. 正常编译 Jar 包, 解压出lib文件夹
  2. 修改 pom.xml 配置,编译出不带 lib 文件夹的 Jar 包
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <mainClass>com.cgp.jar.SpringBootJarApplication</mainClass>
                <layout>ZIP</layout>
                <!--排除第三方jar文件-->
                <includes>
                    <include>
                        <groupId>nothing</groupId>
                        <artifactId>nothing</artifactId>
                    </include>
                </includes>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

配置完成后,再次执行编译

生成的 Jar 包体积明显变小 \3. 运行编译后的 Jar 包 将解压出来的lib文件夹、新编译的jar包放在同一个目录, 运行下面命令 就能成功运行

java -Dloader.path=D:\rental\lib -jar spring-boot-jar-0.0.1-SNAPSHOT.jar

-Xmx256m -Xms256m -jar rental.jar

5.MySQL

1. [Windows下更改MySQL 数据库文件存放位置]

打赏一个呗

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦