我的站点在443和80端口下都有部署,这样访问站点使用http和https时都可以访问到站点,但是使用http访问的站点一直会有不安全提示,这个体验很不好,就需要我们做一点工作让它自动跳转到有证书的https站点下面。 本文以站点https://www.huibenit.com为例说明怎么设置,服务器操作系统:windows2012 R2, IIS8.5 首先要做的准备是下载微软IIS下的一个Url重写模块 url-rewrite;下载地址:http://www.iis.net/downloads/microsoft/url-rewrite,目前的版本是2.1支持IIS7和IIS8。下载好后一路默认下一步安装完。 下面就开始介绍如何配置: (1)在运行里输入inetmgr打开IIS站点管理窗口,然后选择你需要设置的站点,找到Url 重写(Url rewrite)如下图所示: (2)双击“Url 重写”模块进入设置窗口,然后在右上角找到添加规则按钮,点击后如下图,再选择“空白规则”。 (3)规则设置如下: 名称:HTTPS跳转 条件:{HTTPS} 模式:off 操作类型选择:重定向 重定向URL:https://{HTTP_HOST}/{R:1} (4)最后填写完成后请点击右上角的应用(此步最重要)。 其实上面的设置过程只是一个图形操作窗口,最后填写的内容会保存在Web.Config中。我们也是可以通过修改web.config来实现上面的填写过程。 我把完整的Web.config粘贴出来如下:
|
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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
<?xml version="1.0" encoding="utf-8"?> <!-- For more information on how to configure your ASP.NET application, please visit https://go.microsoft.com/fwlink/?LinkId=301880 --> <configuration> <appSettings> <add key="webpages:Version" value="3.0.0.0" /> <add key="webpages:Enabled" value="false" /> <add key="ClientValidationEnabled" value="true" /> <add key="UnobtrusiveJavaScriptEnabled" value="true" /> </appSettings> <system.web> <compilation targetFramework="4.6.1" /> <httpRuntime targetFramework="4.6.1" /> <httpModules> <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" /> </httpModules> </system.web> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" /> <bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" /> </dependentAssembly> </assemblyBinding> </runtime> <system.webServer> <validation validateIntegratedModeConfiguration="false" /> <modules> <remove name="ApplicationInsightsWebTracking" /> <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" /> </modules> <rewrite> <rules> <rule name="HTTPS跳转" stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="{HTTPS}" pattern="off" /> </conditions> <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" /> </rule> </rules> </rewrite> </system.webServer> <system.codedom> <compilers> <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" /> <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" /> </compilers> </system.codedom> </configuration> |
是不是很简单?只需要添加节:
|
1 2 3 4 5 6 7 8 9 10 11 |
<rewrite> <rules> <rule name="HTTPS跳转" stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="{HTTPS}" pattern="off" /> </conditions> <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" /> </rule> </rules> </rewrite> |
from:https://lebang2020.cn/details/210106t51nqtom.html
View DetailsQueryWrapper queryWrapper = new QueryWrapper<>(); 查询指定字段 通过select()查询指定字段,同时可对字段进行Mysql函数处理
|
1 |
queryWrapper.select("service_code as serviceCode", "sum(num) as num"); |
设置limit 通过last(),效果等同于limit
|
1 |
queryWrapper.last("limit 0,5"); |
查询条件中使用函数 例如,在查询IP时,想使用INET_ATON()函数,可以使用apply()实现
|
1 2 |
queryWrapper.apply("INET_ATON(qsip) <= INET_ATON({0})", ipQuery); queryWrapper.apply("INET_ATON(zzip) >= INET_ATON({0})", ipQuery); |
from:https://blog.csdn.net/qq_42594278/article/details/106625280
View Details博主在最近的开发中又遇到了关于定时调度的开发任务,在定时调度其实有很多的第三方平台可以接入,但是其实在SpringBoot有自带的定时任务注解@Scheduled。@Scheduled可以通过注解配置快速实现方法的定时调度,直接在方法加上@Scheduled注解即可。 一.@Scheduled注解参数 1.cron参数 这个参数是最经常使用的参数,表示接收一个cron参数,cron它是一个表达式,最多接收7个参数,从左到右分别表示:秒 分 时 天 月 周 年;参数以空格隔开,其中年不是必须参数,可以省略。
|
1 2 3 4 5 6 7 8 |
/** * cron 一共可以有7个参数 以空格分开 其中年不是必须参数 * [秒] [分] [小时] [日] [月] [周] [年] * 一下表示 */ @Scheduled(cron ="0 0 0 * * * ?") public void testScheduledCron(){ } |
注意!!! 在使用时需要在类上添加注解@EnableScheduling,表示开启定时任务。 cron参数意义: 序号 含义 是否必填 入参范围 可填通配符 1 秒 是 0-59 , – * / 2 分 是 0-59 , – * / 3 时 是 0-23 , – * / 4 日 是 1-31 , – * ? / L W 5 月 是 1-12 , – * / 6 周(周一 ~ 周日) 是 1-7 , – * ? / L # 8 年 否 1970-2099 , – * / 常用通配符: *:表示所有值 比如用在日 表示每一天。 ?:表示不指定值 比如周配置 […]
View Details1.单表查询
|
1 2 3 4 5 6 7 8 9 |
@GetMapping("/list") public TableDataInfo list(Student student){ LambdaQueryWrapper<Student> lqw = new LambdaQueryWrapper<Student>(); lqw.eq(Student::getName, student.getName()); lqw.like(Student::getClass,student.getClass()); lqw.between("age",student.getAge1(),student.getAge2()); lqw.orderByAsc("age"); List<Student> list = studentService.list(lqw); } |
对应的sql语句为:
|
1 |
select * from student where name = '?' and class like '%?%' and age between '?' and '?' order by '?' asc |
1.1、单表查询的基本用法 函数名 说明 例子 eq 等于 例:eq(“name”,“张子”) ===> name = ‘张子’ ne 不等于 例:ne(“name”,“张子”) ===> name <> ‘张子’ gt 大于 例:gt(“age”,“18”) ===> age>18 lt 小于 例:lt(“age”,“18”) ===> age<18 between 在值1到值2之间 例:between(“age”,18,30) ===> 18<age<30’ like 模糊查询 例:like(“name”,“张”) ===> name like ‘%张%’ isNull 字段为NULL 例:isNull(“name”) ===> name is null 2、多表查询
|
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 |
//Controller @GetMapping("/listAndClass") public TableDataInfo listAndClass(Student student) { QueryWrapper<Student > qw = new QueryWrapper<Student >(); if(StringUtils.isNotBlank(student.getName())){ qw.eq("s.name",student.getName()); } if(StringUtils.isNotBlank(student.getClassName())){ qw.like("c.name",student.getClassName()); } startPage(); List<Student > list = studentService.listAndClass(qw); return getDataTable(list); } //Service List<Student> listAndClass(QueryWrapper<Student> qw); //Service impl @Override public List<Student> listAndClass(QueryWrapper<Student> qw) { return this.getBaseMapper().listAndClass(qw); } //Mapper @Select("select s.*,c.name from student s left join class c on s.id = c.student_id "+ "${ew.customSqlSegment}") List<YwSpaqjgDj> listAndClass(@Param(Constants.WRAPPER) QueryWrapper<Student> qw); |
from:https://www.cnblogs.com/gongss/p/16727090.html
View Details//SerializerFeature.WriteDateUseDateFormat 使用日期字段格式序列化(2017-01-01),而不是用时间戳表示日期 JSON.toJSONString(data, SerializerFeature.WriteDateUseDateFormat)); from:https://www.cnblogs.com/gossip/p/6963957.html
View Details1. 单独仓库配置 打开Maven配置文件 apache-maven-3.6.3\conf\settings.xml 在<mirrors></mirrors>标签里新增一个mirror配置即可。
|
1 2 3 4 5 6 7 8 |
<mirrors> <mirror> <id>aliyun</id> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror> </mirrors> |
标签 作用 id 镜像的唯一标识 name 名称描述 url 地址 mirrorOf 指定镜像规则,什么情况下从镜像仓库拉取 mirrorOf规则 作用 * 匹配所有,所有内容都从镜像拉取 external:* 除了本地缓存的所有从镜像仓库拉取 central 覆盖默认的仓库 repo1,repo2 匹配仓库repo1和repo2,使用逗号分割多个远程仓库 比如:镜像配置的规则 <mirrorOf>repo1</mirrorOf>,意为:匹配到目标仓库 <id>repo1</id>; 所以maven认为目标仓库central被镜像了; 不再去 https://repo.maven.apache.org/maven2/ 地址下载jar包; 而是去镜像仓库 http://maven.aliyun.com/nexus/content/groups/public/ 下载jar包。 2. 多仓库配置 有时候我们需要的jar包公有仓库没有,此时就必须启用多仓库配置,使maven同时使用私有仓库和公有仓库。 在<profiles></profiles>标签里配置多个profile配置。
|
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 39 40 41 42 43 44 45 46 47 48 49 50 |
<profiles> <profile> <id>aliyun-repo</id> <repositories> <repository> <id>aliyun</id> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> <updatePolicy>always</updatePolicy> </snapshots> </repository> </repositories> </profile> <profile> <id>jboss-repo</id> <repositories> <repository> <id>jboss</id> <url>http://repository.jboss.org/nexus/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> <updatePolicy>always</updatePolicy> </snapshots> </repository> </repositories> </profile> <profile> <id>maven-repo</id> <repositories> <repository> <id>maven2</id> <url>http://central.maven.org/maven2/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> <updatePolicy>always</updatePolicy> </snapshots> </repository> </repositories> </profile> <profiles> |
在<activeProfiles></activeProfiles>标签里使用<activeProfile></activeProfile>标签启用配置。
|
1 2 3 4 5 |
<activeProfiles> <activeProfile>aliyun-repo</activeProfile> <activeProfile>jboss-repo</activeProfile> <activeProfile>maven-repo</activeProfile> </activeProfiles> |
from:https://www.aliang.link/pages/df2aeb/#_2-%E5%A4%9A%E4%BB%93%E5%BA%93%E9%85%8D%E7%BD%AE
View Details一. 问题现象
ping公网域名失败,提示Name or service not known,但可以ping通弹性公网IP。
二. 问题根因
出现该问题通常有三个原因:
/etc/resolv.conf未配置DNS地址或者DNS地址错误导致。
/etc/nsswitch.conf文件删除DNS解析记录导致。
/lib64/libnss_dns.so.2库文件丢失导致无法解析域名。
问题:安装java出现内部错误61003,安装成功输入java -version提示无法打开dll文件
原因:没有装visual c++2015 redistributable
解决方案 下载并安装该插件
安装 visual c++2015 redistributable
链接 https://www.microsoft.com/en-us/download/details.aspx?id=48145
View Details1.java.lang.System类 该方法的作用是返回当前的计算机时间,时间的表达格式为当前计算机时间和GMT时间(格林威治时间)1970年1月1号0时0分0秒所差的毫秒数。
|
1 |
System.currentTimeMillis(); |
2.Calendar类 先由getInstance获取Calendar对象,然后用clear方法将时间重置为(1970.1.1 00:00:00),接下来用set方法设定指定时间,最后用getTimeMillis获取毫秒值。
|
1 2 3 4 5 6 |
Calendar calendar = Calendar.getInstance(); calendar.clear(); //指定时间的毫秒数 calendar.set(2021, 0, 1); long millis = calendar.getTimeInMillis(); |
※ Calendar 的 month 从 0 开始,也就是全年 12 个月由 0 ~ 11 进行表示。 3.java.util.Date类、SimpleDateFormat类 先由时间格式创建SimpleDateFormat对象,然后通过parse方法由指定时间创建Date对象,最后由Date对象的getTime方法获取毫秒值。
|
1 2 3 4 5 6 7 8 9 10 11 |
SimpleDateFormat format = new SimpleDateFormat("yyyy-mm-dd"); Date date = null; try { //指定时间的毫秒数 date = format.parse("2021-01-01"); } catch (ParseException e) { e.printStackTrace(); } long millis = date.getTime(); |
测试
|
1 2 3 4 5 6 7 8 9 10 |
public static void test() { long curTime1 = System.nanoTime(); System.out.println("System.currentTimeMillis() " + System.currentTimeMillis() + " 耗时(ns):" + (System.nanoTime() - curTime1)); long curTime2 = System.nanoTime(); System.out.println("new Date().getTime() " + new Date().getTime() + " 耗时(ns):" + (System.nanoTime() - curTime2)); long curTime3 = System.nanoTime(); System.out.println("Calendar.getInstance().getTimeInMillis() " + Calendar.getInstance().getTimeInMillis() + " 耗时(ns):" + (System.nanoTime() - curTime3)); } |
结果 System.currentTimeMillis() 1630315030949 耗时(ns):39600 new Date().getTime() 1630315030949 耗时(ns):500300 Calendar.getInstance().getTimeInMillis() 1630315030956 耗时(ns):19424400 参考: https://www.cnblogs.com/jpfss/p/10455524.html 转载请注明出处:BestEternity亲笔。 from:https://blog.csdn.net/BestEternity/article/details/119998914
View DetailsSpring 事务管理分为编码式和声明式的两种方式。编程式事务指的是通过编码方式实现事务;声明式事务基于AOP,将具体业务逻辑与事务处理解耦。
声明式事务管理使业务代码逻辑不受污染, 因此在实际使用中声明式事务用的比较多。
声明式事务有两种方式,一种是在配置文件中做相关的事务规则声明,另一种是基于@Transactional 注解的方式。