您正在查看: Other 分类下的文章

Maven打jar包的三种方式

不包含依赖jar包

该方法打包的jar,不包含依赖的jar包,也没有指定入口类。

<build>
    <plugins>
        <plugin>
            <!-- 指定项目编译时的java版本和编码方式 -->
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.0</version>
            <configuration>
                <target>1.8</target>
                <source>1.8</source>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>
    </plugins>
</build>

将依赖jar包输出到指定目录

该方法打包的jar,指定了入口类,可以直接使用java -jar project.jar执行,
但是第三方依赖存在一个指定的外部目录下,迁移时需将jar和依赖目录一起迁移。

<build>
    <plugins>
        <plugin>
            <!-- 指定项目编译时的java版本和编码方式 -->
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.0</version>
            <configuration>
                <target>1.8</target>
                <source>1.8</source>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>3.1.0</version>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>com.netty.client.SignalClient</mainClass> <!-- 指定入口类 -->
                        <addClasspath>true</addClasspath> <!-- 在jar的MF文件中生成classpath属性 -->
                        <classpathPrefix>lib/</classpathPrefix> <!-- classpath前缀,即依赖jar包的路径 -->
                    </manifest>
                </archive>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>3.1.1</version>
            <executions>
                <execution>
                    <id>copy</id>
                    <phase>install</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <!-- 指定依赖包的输出路径,需与上方的classpathPrefix保持一致 -->
                        <outputDirectory>${project.build.directory}/lib</outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

将项目依赖和项目打成一个jar包

该方法打包的jar,指定了入口类,可以直接使用java -jar project.jar执行,
并且将第三方依赖打到了项目jar包中。

<build>
    <plugins>
        <plugin>
            <!-- 指定项目编译时的java版本和编码方式 -->
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.0</version>
            <configuration>
                <target>1.8</target>
                <source>1.8</source>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>3.1.0</version>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>com.netty.client.SignalClient</mainClass> <!-- 指定入口类路径 -->
                    </manifest>
                </archive>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef> <!-- jar包后缀,生成的jar包形式为:project-1.0-SNAPSHOT-jar-with-dependencies.jar -->
                </descriptorRefs>
            </configuration>
            <!-- 添加此项后,可直接使用mvn package | mvn install -->
            <!-- 不添加此项,需直接使用mvn package assembly:single -->
            <executions>
                <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

转载自:https://www.cnblogs.com/jinjiyese153/p/9374015.html

idea 使用中遇到的坑,持续总结

常见问题

  1. META-INF 修改路径为
    src/main/resources
  2. 编辑 META-INF\MANIFEST.MF,不然被三方加载,启动时找不到主类
    Main-Class: Main

参考

https://www.cnblogs.com/Bruce_H21/p/9909198.html

解决Unexpected end of JSON input while parsing near 问题

终端执行命令npm cache clean --force
完成后再执行命令npm install

Install MySQL 8 on Windows 10 64bit

下载

下载地址:https://dev.mysql.com/downloads/mysql/8.0.html

1.解压

mysql-8.0.19-winx64.zip

演示文件目录

C:\Program Files\mysql-8.0.19-winx64

2.创建两个文件夹

C:\Program Files\mysql-8.0.19-winx64\data
C:\Program Files\mysql-8.0.19-winx64\logs

3.设置环境变量

4.新建my.ini配置

[mysqld]
#安装目录
basedir = C:\Program Files\mysql-8.0.19-winx64
#数据文件目录
datadir = C:\Program Files\mysql-8.0.19-winx64\data
port = 3306
server_id = 1
general_log = ON
general_log_file = C:\Program Files\mysql-8.0.19-winx64\logs\mysql.log
log_error = C:\Program Files\mysql-8.0.19-winx64\logs\error.log
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 
character-set-server = utf8mb4
performance_schema_max_table_instances = 600
table_definition_cache = 400
table_open_cache = 256
#sql_mode=ONLY_FULL_GROUP_BY,NO_AUTO_VALUE_ON_ZERO,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,PIPES_AS_CONCAT,ANSI_QUOTES
[mysql]
default-character-set = utf8mb4

[client]
default-character-set = utf8mb4

5.管理员权限开启CMD窗口

5.1 初始化
mysqld --initialize --console #不用特别指定default file默认会使用my.ini

控制台输入如下表示成功

C:\Program Files\mysql-8.0.19-winx64>mysqld --initialize --console
2020-04-21T10:11:25.148253Z 0 [Warning] [MY-010915] [Server] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2020-04-21T10:11:25.148318Z 0 [System] [MY-013169] [Server] C:\Program Files\mysql-8.0.19-winx64\bin\mysqld.exe (mysqld 8.0.19) initializing of server in progress as process 8684
2020-04-21T10:11:47.571686Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Fv?_a7%jn_R(

Warning暂时没做理会,没发现使用异常
记下上面日志最后面的root的初始化密码Fv?_a7%jn_R(,下面要用到

5.2 安装服务
mysqld --install [服务名] #不写服务名默认为mysql
5.3 启动数据库
C:\Program Files\mysql-8.0.19-winx64>net start mysql
MySQL 服务正在启动 ..
MySQL 服务已经启动成功。
5.4 使用临时密码登陆数据库
C:\Program Files\mysql-8.0.19-winx64>mysql -u root -p
Enter password: ************
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.19

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
5.5 修改root初始化密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '要改的新密码';

统计github本地仓库的代码行数

git ls-files | xargs wc -l