1.在pom文件添加一行打包的配置
|
1 |
<packaging>jar</packaging> |
再添加一个spring-boot-maven-plugin打包插件
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> </plugins> </build> |
由于我的8080端口已经被占用了 ,所以我要先改下项目端口,如果你的8080端口没被占用不需要改 打开Run/Debug Configurations对话框添加一个Maven打包配置,如图 然后运行mvn就可以生成jar包 在项目的target目录可以看到生成的jar包 打开cmd,到jar 包所在目录 运行命令 java -jar springboot-0.0.1-SNAPSHOT.jar 浏览器访问结果 使用eclipse打成jar包 1.项目右键 debug as-> Debug Configurations 点击Debug即可。 当然你也可以选择打成war包,需要把pom里的jar改成war,打包后放到Tomcat的webapp下启动Tomcat就可以了。但是必须使用1.8的jdk和8.0以上的Tomcat ,且必须配置JAVA_HOME环境变量,这里我就不演示了。 from:https://blog.csdn.net/wya1993/article/details/79582014
View Details在pom文件中,添加如下即可:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> |
from:https://blog.csdn.net/qq_18769269/article/details/83095012
View Details【1】项目内部配置文件 spring boot 启动会扫描以下位置的application.properties或者application.yml文件作为Spring boot的默认配置文件
|
1 2 3 4 |
–file:./config/ –file:./ –classpath:/config/ –classpath:/ |
即如下图所示: 以上是按照优先级从高到低的顺序,所有位置的文件都会被加载,高优先级配置内容会覆盖低优先级配置内容。 SpringBoot会从这四个位置全部加载主配置文件,如果高优先级中配置文件属性与低优先级配置文件不冲突的属性,则会共同存在—互补配置。 我们也可以通过配置spring.config.location来改变默认配置。
|
1 2 |
java -jar spring-boot-02-config-02-0.0.1-SNAPSHOT.jar --spring.config.location=D:/application.properties |
项目打包好以后,我们可以使用命令行参数的形式,启动项目的时候来指定配置文件的新位置。 指定配置文件和默认加载的这些配置文件共同起作用形成互补配置。 【2】外部配置加载顺序 SpringBoot也可以从以下位置加载配置:优先级从高到低;高优先级的配置覆盖低优先级的配置,所有的配置会形成互补配置。 1.命令行参数 所有的配置都可以在命令行上进行指定; 多个配置用空格分开; –配置项=值
|
1 2 |
java -jar spring-boot-02-config-02-0.0.1-SNAPSHOT.jar --server.port=8087 --server.context-path=/abc |
2.来自java:comp/env的JNDI属性 3.Java系统属性(System.getProperties()) 4.操作系统环境变量 5.RandomValuePropertySource配置的random.*属性值 6.jar包外部的application-{profile}.properties或application.yml(带spring.profile)配置文件 7.jar包内部的application-{profile}.properties或application.yml(带spring.profile)配置文件 8.jar包外部的application.properties或application.yml(不带spring.profile)配置文件 9.jar包内部的application.properties或application.yml(不带spring.profile)配置文件
|
1 |
由jar包外向jar包内进行寻找,优先加载待profile的,再加载不带profile的。 |
10.@Configuration注解类上的@PropertySource 11.通过SpringApplication.setDefaultProperties指定的默认属性 参考官网地址 官网图示如下: from:https://blog.csdn.net/j080624/article/details/80508606
View Details设置PHP脚本执行超时的时间有下面这样一些方法: php.ini 中限定程序的最长执行时间是 30 秒,这是由 php.ini 配置文件中的 max_execution_time 变量指定,倘若你有一个需要颇多时间才能完成的程序代码,代码会由于超时而执行失败,例如要发送很多电子邮件给大量收件者,或者要进行繁重的数据分析工作,服务器会在 30 秒后强行中止正在执行的程序,如何解决这个问题呢。 一、在php.ini里面设置 max_execution_time = 1800; 二、通过PHP的ini_set 函数设置 ini_set("max_execution_time", "1800"); 三、通过set_time_limit 函数设置 set_time_limit(1800) ; ——————— 作者:YOYOYOHUI 来源:CSDN 原文:https://blog.csdn.net/yoyoyohui/article/details/83009250 版权声明:本文为博主原创文章,转载请附上博文链接!
View Detailsyarn的简介: Yarn是facebook发布的一款取代npm的包管理工具。 yarn的特点: 速度超快。 Yarn 缓存了每个下载过的包,所以再次使用时无需重复下载。 同时利用并行下载以最大化资源利用率,因此安装速度更快。 超级安全。 在执行代码之前,Yarn 会通过算法校验每个安装包的完整性。 超级可靠。 使用详细、简洁的锁文件格式和明确的安装算法,Yarn 能够保证在不同系统上无差异的工作。 yarn的安装: 下载node.js,使用npm安装 npm install -g yarn 查看版本:yarn --version 安装node.js,下载yarn的安装程序: 提供一个.msi文件,在运行时将引导您在Windows上安装Yarn Yarn 淘宝源安装,分别复制粘贴以下代码行到黑窗口运行即可 yarn config set registry https://registry.npm.taobao.org -g yarn config set sass_binary_site http://cdn.npm.taobao.org/dist/node-sass -g yarn的常用命令: 安装yarn npm install -g yarn 安装成功后,查看版本号: yarn --version 创建文件夹 yarn md yarn 进入yarn文件夹 cd yarn 初始化项目 yarn init // 同npm init,执行输入信息后,会生成package.json文件 yarn的配置项: yarn config list // 显示所有配置项 yarn config get <key> //显示某配置项 yarn config delete <key> //删除某配置项 yarn config set <key> <value> [-g|--global] //设置配置项 安装包: yarn install //安装package.json里所有包,并将包及它的所有依赖项保存进yarn.lock yarn install […]
View Details今天把博客布置上线,运行完composer install之后,报错It is unsafe to run Dusk in production.。 这是因为安装了dusk包,当你的APP_ENV=local、testing时是本地测试环境,他就是用来检测代码的质量如何,所以不会抛出这个异常。但是当你的APP_ENV=production时,也就是你部署到线上了,这个包会暴露很多接口以及程序信息,会给你的程序带来致命的危险。 解决办法也很简单,要么在线上的时候把这个包给删除掉。要么就是在安装这个包的时候,将他放在composer.json文件的require-dev下面,在线上composer安装完毕,再运行一下
|
1 |
composer install --no-dev |
问题解决。 from:https://www.guangsky.com/article/1
View Details通过 git clone 下来的 laravel 项目,因为 .gitignore 文件设置了忽略项的原因,没有/vendor目录和 /node_modules,所以直接跑是肯定跑不起来的。这时候,就需要还原 laravel 项目。 首先进入 clone 下来的项目文件 1、还原 vendor 目录
|
1 |
composer install |
2、还原 node_modules 目录
|
1 |
npm install |
或者(使用了淘宝源的话)
|
1 |
cnpm install |
3、还原 .env
|
1 2 |
cp .env.example .env php artisan key:generate |
接着按照自身情况配置 .env 4、还原 homestead.yaml
|
1 |
php vendor/bin/homestead make |
5、启动 homestead
|
1 |
vagrant up |
6、还原数据库
|
1 2 3 4 |
vagrant ssh cd XXXX php artisan migrate php artisan db:seed |
这样就恢复了 laravel 项目。 作者:Arnold_Z 链接:https://www.jianshu.com/p/dd16a9d499b9 来源:简书 简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。
View Details*eclipse默认tomcat下是自动完成编译;而Intellij Idea默认tomcat下不是自动完成编译,从如下开始设置: 进入“settings”,如下图找到“compiler”,选中如图框选选项 勾选“Build project automatically”,保存即可。 from:https://www.cnblogs.com/zdb292034/p/8047267.html
View Details第一步在我们的电脑上打开IntelliJ IDEA,点击File->Settings,如下图所示: 第二步进去Settings之后,点击 Compiler,如下图所示: 第三步勾选“Build project automatically”,点击OK,如下图所示: 第四步按“ctrl+alt+shift+/”键,选择Registry ,如下图所示: 第五步勾选“compiler.automake.allow.when.app.running”,保存之后,进行重启IntelliJ IDEA就完成了,如下图所示: from:https://jingyan.baidu.com/article/ca2d939d5b0c05eb6d31ce77.html
View DetailsRSA 是一种非对称加密算法。由于算法特性,加密和解密过程用不同密钥,即公钥和私钥,而被广泛应用于数字证书的安全管理。 在具体应用中,公钥用加密而私钥用于解密,或 私钥用于数字签名而公钥用于签名验证。由于非对称加密算法比价复杂,耗时较长,所以一般在网络环境中RAS 被应用于 签名认证,或小数据传输,如 AES 对称密钥传输。 在.Net 框架中,默认提供的辅助类只能对密钥长度大小相同的数据进行加密解密。 此文提供C# RSA 算法示例一座优化,可以不限数据大小。此实例 仅供交流学习。 RSA 加密
|
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 36 37 38 |
public string RsaEncrypt(string rawInput, string publicKey) { if (string.IsNullOrEmpty(rawInput)) { return string.Empty; } if(string.IsNullOrWhiteSpace(publicKey)) { throw new ArgumentException("Invalid Public Key"); } using (var rsaProvider = new RSACryptoServiceProvider()) { var inputBytes = Encoding.UTF8.GetBytes(rawInput);//有含义的字符串转化为字节流 rsaProvider.FromXmlString(publicKey);//载入公钥 int bufferSize = (rsaProvider.KeySize / 8) - 11;//单块最大长度 var buffer = new byte[bufferSize]; using (MemoryStream inputStream = new MemoryStream(inputBytes), outputStream = new MemoryStream()) { while (true) { //分段加密 int readSize = inputStream.Read(buffer, 0, bufferSize); if (readSize <= 0) { break; } var temp = new byte[readSize]; Array.Copy(buffer, 0, temp, 0, readSize); var encryptedBytes = rsaProvider.Encrypt(temp, false); outputStream.Write(encryptedBytes, 0, encryptedBytes.Length); } return Convert.ToBase64String(outputStream.ToArray());//转化为字节流方便传输 } } } |
RSA 解密
|
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 36 37 38 |
public string RsaDecrypt(string encryptedInput, string privateKey) { if (string.IsNullOrEmpty(encryptedInput)) { return string.Empty; } if (string.IsNullOrWhiteSpace(privateKey)) { throw new ArgumentException("Invalid Private Key"); } using (var rsaProvider = new RSACryptoServiceProvider()) { var inputBytes = Convert.FromBase64String(encryptedInput); rsaProvider.FromXmlString(privateKey); int bufferSize = rsaProvider.KeySize / 8; var buffer = new byte[bufferSize]; using (MemoryStream inputStream = new MemoryStream(inputBytes), outputStream = new MemoryStream()) { while (true) { int readSize = inputStream.Read(buffer, 0, bufferSize); if (readSize <= 0) { break; } var temp = new byte[readSize]; Array.Copy(buffer, 0, temp, 0, readSize); var rawBytes = rsaProvider.Decrypt(temp, false); outputStream.Write(rawBytes, 0, rawBytes.Length); } return Encoding.UTF8.GetString(outputStream.ToArray()); } } } |
from:https://blog.csdn.net/hangzhi22/article/details/53089154
View Details