ActiveMQ配置初探
文章目录
- 配置
- wrapper相关配置
- wrapper是干什么用的
- MQ的运行内存修改【需修改】
- 修改内容
- 题外话
- wrapper.log配置【需修改】
- 引起的问题
- 优化方式
- activemq.xml相关配置
- 官网介绍
- 配置管理后台的认证授权【建议修改】
- 配置broker【根据自己需求更改】
- 配置允许jmx监控
- 关闭消息通知
- 持久化发布订阅模式(topic)管理
- 删除过期的消息
- 删除已经不活跃额订阅者
- 队列模式(queue)管理
- 配置参数
- 认证授权
- 明文配置方式
- activemq.xml中的配置
- 代码中的配置
- 加密配置方式
- 统一配置时间
- 死信队列抛弃策略
- 死信队列是什么呢?
- 配置方式
- 持久化配置
- kahaDB配置
- 存储空间设置
- kahaDB日志【测试时才用,测试环境和生产环境不能配置】
- 示例配置
- activemq.xml
- 原文件
- activemq.xml
配置
wrapper相关配置
wrapper是干什么用的
ActiveMQ官网上是这么写的(戳此跳转到官网页面):
ActiveMQ uses the Java Service Wrapper to run the broker. To configure how the Java Service Wrapper starts up, you can edit the wrapper.conf located in the bin/win32, bin/linux, or bin/macosx depending on which system you are running it. For more information on the different properties of the Java Service Wrapper, refer to this page
wrapper是个将java打包成windows或者unix的服务的一个工具。它同时还为应用程序提供日记功能,灵活的配置,可靠的运行性能,按需求重新启动,简化应用程序的安装等。
MQ的运行内存修改【需修改】
修改内容
当你下载MQ并解压之后,你会发现文件夹如下所示(下图中,上面为macox、linux版,下图为windows版)
修改内存可通过修改wrapper.conf文件中的如下命令。
注意此处是通过什么方式启动,就修改哪个文件夹的wrapper.conf啊!比如你是win64启动方式,就改win64文件夹下的.conf,并且你运行的时候也是用win64文件夹下的activemq.bat哈
# Initial Java Heap Size (in MB)
# 等同于xms
wrapper.java.initmemory=1024# Maximum Java Heap Size (in MB)
# 等同于xmx
wrapper.java.maxmemory=1024
题外话
在研究的过程中,发现了一个很有意思的东西,在此赘述下。
在bin文件夹下的activemq(unix可执行文件)的源代码中,发现了一个备注
# System variables for this script, like ACTIVEMQ_OPTS and ACTIVEMQ_OPTS_MEMORY,
# can be configured in 'env' script located in this directory.
并且在activemq(unix可执行文件)中,也能看到代码为
if [ -z "$ACTIVEMQ_OPTS" ] ; thenACTIVEMQ_OPTS="$ACTIVEMQ_OPTS_MEMORY -Djava.util.logging.config.file=logging.properties -Djava.security.auth.login.config=$ACTIVEMQ_CONF/login.config"
fi
然后编辑env文件(windows版没有该文件)其中有一段代码如下
if [ -z "$ACTIVEMQ_OPTS_MEMORY" ] ; thenACTIVEMQ_OPTS_MEMORY="-Xms64M -Xmx1G"
fi
if [ -z "$ACTIVEMQ_OPTS" ] ; thenACTIVEMQ_OPTS="$ACTIVEMQ_OPTS_MEMORY -Djava.util.logging.config.file=logging.properties -Djava.security.auth.login.config=$ACTIVEMQ_CONF/login.config"
fiif [ -z "$ACTIVEMQ_OUT" ]; thenACTIVEMQ_OUT="/dev/null"
fi
也就是说,在此处也可以进行配置,经过测试发现,如果会用bin目录下的activemq进行启动(当然此处window没法用这个启动),就会使用到这个内存修改参数。
-
如果此文件修改了,使用的bin/xxx/下的activemq,最终wrapper会覆盖掉这个文件夹下的参数;
-
如果此文件修改了,使用的bin下的activemq,最终使用的是env下的参数;
下图为使用单独文件夹下的activemq启动,如图所示
下图为使用bin目录下的activemq启动,如图所示
两者启动的形成的命令行如下(在macos上,其余系统未尝试)
java -Xms64M -Xmx1G -Djava.util.logging.config.file=logging.properties -Djava.security.auth.login.config=/apache-activemq-5.16.6/conf/login.config -Dcom.sun.management.jmxremote -Djava.awt.headless=true -Djava.io.tmpdir=/apache-activemq-5.16.6//tmp -Dactivemq.classpath=/apache-activemq-5.16.6//conf:/apache-activemq-5.16.6//../lib/: -Dactivemq.home=/apache-activemq-5.16.6/ -Dactivemq.base=/apache-activemq-5.16.6/ -Dactivemq.conf=/apache-activemq-5.16.6//conf -Dactivemq.data=/apache-activemq-5.16.6//data -jar //apache-activemq-5.16.6//bin/activemq.jar start
/apache-activemq-5.16.6/bin/macosx/wrapper /apache-activemq-5.16.6/bin/macosx/wrapper.conf wrapper.syslog.ident=ActiveMQ wrapper.pidfile=/apache-activemq-5.16.6/bin/macosx/./ActiveMQ.pid wrapper.daemonize=TRUE/usr/bin/java -Dactivemq.home=../.. -Dactivemq.base=../.. -Djavax.net.ssl.keyStorePassword=password -Djavax.net.ssl.trustStorePassword=password -Djavax.net.ssl.keyStore=../../conf/broker.ks -Djavax.net.ssl.trustStore=../../conf/broker.ts -Dcom.sun.management.jmxremote -Dorg.apache.activemq.UseDedicatedTaskRunner=false -Djava.util.logging.config.file=logging.properties -Dactivemq.conf=../../conf -Dactivemq.data=../../data -Djava.security.auth.login.config=../../conf/login.config -Xms1024m -Xmx1024m -Djava.library.path=../../bin/macosx/ -classpath ../../bin/wrapper.jar:../../bin/activemq.jar -Dwrapper.key=ZpwQ3RjSWlo75KaJ -Dwrapper.port=32000 -Dwrapper.jvm.port.min=31000 -Dwrapper.jvm.port.max=31999 -Dwrapper.pid=87518 -Dwrapper.version=3.2.3 -Dwrapper.native_library=wrapper -Dwrapper.service=TRUE -Dwrapper.cpu.timeout=10 -Dwrapper.jvmid=1 org.tanukisoftware.wrapper.WrapperSimpleApp org.apache.activemq.console.Main start
从启动命令能大概看出来,使用wrapper的方式启动,能覆盖到直接用unix执行命令启动
wrapper.log配置【需修改】
引起的问题
ActiveMQ服务器data目录下wrapper.log文件,默认产生的日志是不覆盖的,文件的大小逐渐增大。累加后会出现文件越来越大。所以建议此处进行优化。找到以下代码进行修改。如下面因为所示,一个是最大的文件大小,和最多的文件数量。
优化方式
# Maximum size that the log file will be allowed to grow to before
# the log is rolled. Size is specified in bytes. The default value
# of 0, disables log rolling. May abbreviate with the 'k' (kb) or
# 'm' (mb) suffix. For example: 10m = 10 megabytes.
wrapper.logfile.maxsize=20m# Maximum number of rolled log files which will be allowed before old
# files are deleted. The default value of 0 implies no limit.
wrapper.logfile.maxfiles=100
activemq.xml相关配置
官网介绍
默认的activemq.xml的原文件,详见最后的源文件,其相关内容的配置,详见“极其复杂的官网配置页面”
配置管理后台的认证授权【建议修改】
activemq在登录管理后台的时候,是会需要账号密码的。如果需要修改管理后台的登录账号密码,可以修改"conf/jetty-realm.properties/jetty-realm.properties"文件,文件内容如下:
# Defines users that can access the web (console, demo, etc.)
# username: password [,rolename ...]
admin: admin, admin
user: user, user
修改形式为 “用户名: 密码, 角色”,此处角色是怎么配置的,比较复杂,可以见"conf/jetty-realm.properties/jetty.xml"
配置broker【根据自己需求更改】
broker就相当于一个Activemq实例
配置允许jmx监控
<!-- 允许使用jmx监控 --><broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="${activemq.data}" useJmx="true">...</broker>
关闭消息通知
消息通知指的是broker上的操作记录的跟踪和通知,可通过配置关闭
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="${activemq.data}" advisorySupport="false">...</broker>
持久化发布订阅模式(topic)管理
按照官网的解释,系统中不应该有离线的持久化订阅者,这样会浪费众多资源。详见官网
所以建议配置以下参数
删除过期的消息
在对应的entry上增加expireMessagesPeriod配置,比如:
<!-- 每5分钟检查一下所有的过期消息,不配置的话,默认是30秒 -->
<policyEntry topic=">" expireMessagesPeriod="300000"/>
删除已经不活跃额订阅者
在broker的数据上增加以下参数
参数 | 默认 | 中文描述 | 英文描述 |
---|---|---|---|
offlineDurableSubscriberTimeout | -1 | 删除多久不活跃的订阅者(单位毫秒),如果配置为-1,则不删除 | Amount of time (in milliseconds) after which we remove inactive durable subs. Default -1, means don’t remove them |
offlineDurableSubscriberTaskSchedule | 300000 | 检查的频率(单位毫秒) | How often we check (in milliseconds) |
示例:
<!-- 每小时检查离线1天的订阅者 -->
<broker name="localhost" offlineDurableSubscriberTimeout="86400000" offlineDurableSubscriberTaskSchedule="3600000">
.....
</broker>
队列模式(queue)管理
详见官网
配置参数
参数名称 | 描述 | 配置数据 |
---|---|---|
schedulePeriodForDestinationPurge | 检查非活跃状态的queue间隔 | 3600000 |
gcInactiveDestinations | 声明该队列是否要被扫描到,默认是false | |
inactiveTimeoutBeforeGC | 声明该队列闲置多少秒被删除,默认60秒 |
其中上面的闲置,代表“无入队记录及无有效订阅”
示例
<!-- 每10秒检查一次 -->
<broker xmlns="http://activemq.apache.org/schema/core" schedulePeriodForDestinationPurge="10000"><destinationPolicy><policyMap><policyEntries><!-- 所有队列,都被扫毛,闲置30秒就被删除--><policyEntry queue=">" gcInactiveDestinations="true" inactiveTimoutBeforeGC="30000"/></policyEntries></policyMap></destinationPolicy></broker>
认证授权
一个ActiveMQ,不能无认证授权的暴漏在外网中,如果这样,会出现信息泄露的风险。所以需要对ActiveMQ的broker进行认证授权配置,这样系统在连接MQ的时候,就必须配置账号密码,提高mq的安全。
明文配置方式
activemq.xml中的配置
在中,找到标签,在标签前增加以下插件配置:
<plugins><simpleAuthenticationPlugin><users><authenticationUser username="账号" password="密码" groups="组别"/></users></simpleAuthenticationPlugin>
</plugins>
此处账号密码可以写死,也可以通过加载配置文件引入,常用的配置方式是使用activemq.xml里面默认引入的配置文件“credentials.properties”,然后使用里面的配置的用户名和密码
比如:
<plugins><simpleAuthenticationPlugin><users><authenticationUser username="${activemq.username}" password="${activemq.password}" groups="users,admins"/><authenticationUser username="guest" password="${guest.password}" groups="guests"/></users></simpleAuthenticationPlugin>
</plugins>
其中“credentials.properties”引入方式是通过(activemq.xml里面是默认使用的):
<!-- Allows us to use system properties as variables in this configuration file -->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"><property name="locations"><value>file:${activemq.conf}/credentials.properties</value></property>
</bean>
里面的内容是:
# Defines credentials that will be used by components (like web console) to access the brokeractivemq.username=system
activemq.password=manager
guest.password=password
代码中的配置
此处是以springboot为例,代码中需要配置
spring:activemq:broker-url: tcp://127.0.0.1:61616user: systempassword: manager
加密配置方式
具体内容详见官网页面,未仔细研究,大概就是使用credentials_enc.properties的内容,密码形如“ENC(Cf3Jf3tM+UrSOoaKU50od5CuBa8rxjoL)”,如需要可以查看官网
统一配置时间
在broker中使用TimeStampPlugin插件,此为一个时间戳插件,官网解释为:TimeStampPlugin插件
参数 | 默认 | 描述 | 英文描述 |
---|---|---|---|
futureOnly | false | When the plugin will never set a message’s time stamp and expiration time to a value lower than the original values. When the plugin always update a message’s time stamp and expiration time.truefalse | |
ttlCeiling | 0 | 表示过期时间上限(程序写的过期时间不能超过此时间,超过则以此时间为准) | When not zero, this value (in ms) limit the expiration time. |
zeroExpirationOverride | 0 | 表示过期时间(给未分配过期时间的消息分配过期时间) | When not zero this value (in ms) will override the expiration time for messages that do not have an expiration already set. |
也就是统一设置过期时间的上线和默认过期时间
<plugins><!-- 设置全局过期时间 --><!-- 86,400,000 ms = 1 day --><timeStampingBrokerPlugin ttlCeiling="1800000" zeroExpirationOverride="1800000" />
</plugins>
死信队列抛弃策略
死信队列是什么呢?
消息过期后会进入死信队列,如不想抛弃死信队列,默认进入ACTIVEMQ.DLQ队列,且不会自动清除;对于过期的消息进入死信队列还有一些可选的策略:放入各自的死信通道、保存在一个共享的队列(默认),且可以设置是否将过期消息放入队列的开关以及死信队列消息过期时间。
配置方式
使用discardingDLQBrokerPlugin插件,官网解释为:DiscardingDLQBrokerPlugin插件,按照自己的需求,配置一下内容即可
<plugins><!-- 丢弃所有死信--><discardingDLQBrokerPlugindropAll="true" dropTemporaryTopics="true" dropTemporaryQueues="true" /><!-- 丢弃指定死信--><discardingDLQBrokerPlugindropOnly="MY.EXAMPLE.TOPIC.29 MY.EXAMPLE.QUEUE.87" reportInterval="1000" /><!--使用丢弃正则匹配到死信--><discardingDLQBrokerPlugindropOnly="MY.EXAMPLE.TOPIC.[0-9]{3} MY.EXAMPLE.QUEUE.[0-9]{3}" reportInterval="3000"/>
</plugins>
持久化配置
activemq默认的持久化方式为kahaDB,当然如果有特殊需求,还可以配置jdbc作为持久化源。
kahaDB配置
所有参数,详见官网
默认的kahaDB的配置,只有存储路径
<persistenceAdapter><kahaDB directory="${activemq.data}/kahadb"/>
</persistenceAdapter>
可以增加以下配置
<persistenceAdapter><!-- journalMaxFileLength:产生的日志文件最大容量 --><kahaDB directory="${activemq.data}/kahadb" journalMaxFileLength="32mb"></kahaDB>
</persistenceAdapter>
存储空间设置
注意,此处标签有两层,不是我多写了哈
<systemUsage><systemUsage><memoryUsage><!-- 表示ActiveMQ使用的内存 --><memoryUsage percentOfJvmHeap="70" /></memoryUsage><storeUsage><!-- 表示持久化存储文件的大小 --><storeUsage limit="100 gb"/></storeUsage><tempUsage><!-- 非持久化消息的临时内存大小 --><tempUsage limit="50 gb"/></tempUsage></systemUsage>
</systemUsage>
kahaDB日志【测试时才用,测试环境和生产环境不能配置】
在log4j.properties中,增加以下参数,便可以输出kahadb的相关日志
### 测试kahadb,增加日志
log4j.appender.kahadb=org.apache.log4j.RollingFileAppender
log4j.appender.kahadb.file=${activemq.base}/data/kahadb.log
log4j.appender.kahadb.maxFileSize=1024KB
log4j.appender.kahadb.maxBackupIndex=5
log4j.appender.kahadb.append=true
log4j.appender.kahadb.layout=org.apache.log4j.PatternLayout
log4j.appender.kahadb.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
log4j.logger.org.apache.activemq.store.kahadb.MessageDatabase=TRACE, kahadb
示例配置
activemq.xml
<beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsdhttp://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd"><bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"><property name="locations"><value>file:${activemq.conf}/credentials.properties</value></property></bean><bean id="logQuery" class="io.fabric8.insight.log.log4j.Log4jLogQuery"lazy-init="false" scope="singleton"init-method="start" destroy-method="stop"></bean><broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="${activemq.data}" start="false" restartAllowed="false"schedulePeriodForDestinationPurge="3600000"useJmx="true" advisorySupport="false" offlineDurableSubscriberTimeout="12000" offlineDurableSubscriberTaskSchedule="6000" deleteAllMessagesOnStartup="true"><destinationPolicy><policyMap><policyEntries><policyEntry topic=">" expireMessagesPeriod="60000"><pendingMessageLimitStrategy><constantPendingMessageLimitStrategy limit="1000"/></pendingMessageLimitStrategy></policyEntry><policyEntry queue=">" gcInactiveDestinations="true" inactiveTimoutBeforeGC="21600000" strictOrderDispatch="true" expireMessagesPeriod="60000"></policyEntry></policyEntries></policyMap></destinationPolicy><managementContext><managementContext createConnector="false"/></managementContext><persistenceAdapter><kahaDB directory="${activemq.data}/kahadb" lockKeepAlivePeriod="2000" ignoreMissingJournalfiles="true" enableAckCompaction = "true" journalMaxFileLength="32mb"><locker><shared-file-locker lockAcquireSleepInterval="10000" /></locker></kahaDB></persistenceAdapter><plugins><timeStampingBrokerPlugin ttlCeiling="1800000" zeroExpirationOverride="1800000" /><discardingDLQBrokerPlugin dropAll="true" dropTemporaryTopics="true" dropTemporaryQueues="true" /></plugins><systemUsage><systemUsage><memoryUsage><memoryUsage percentOfJvmHeap="70" /></memoryUsage><storeUsage><storeUsage limit="100 gb"/></storeUsage><tempUsage><tempUsage limit="50 gb"/></tempUsage></systemUsage></systemUsage><transportConnectors><transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/><transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/><transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/><transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/><transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/></transportConnectors><shutdownHooks><bean xmlns="http://www.springframework.org/schema/beans" class="org.apache.activemq.hooks.SpringContextHook" /></shutdownHooks></broker><import resource="jetty.xml"/></beans>
原文件
activemq.xml
<!--Licensed to the Apache Software Foundation (ASF) under one or morecontributor license agreements. See the NOTICE file distributed withthis work for additional information regarding copyright ownership.The ASF licenses this file to You under the Apache License, Version 2.0(the "License"); you may not use this file except in compliance withthe License. You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.
-->
<!-- START SNIPPET: example -->
<beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsdhttp://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd"><!-- Allows us to use system properties as variables in this configuration file --><bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"><property name="locations"><value>file:${activemq.conf}/credentials.properties</value></property></bean><!-- Allows accessing the server log --><bean id="logQuery" class="io.fabric8.insight.log.log4j.Log4jLogQuery"lazy-init="false" scope="singleton"init-method="start" destroy-method="stop"></bean><!--The <broker> element is used to configure the ActiveMQ broker.--><broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="${activemq.data}"><destinationPolicy><policyMap><policyEntries><policyEntry topic=">" ><!-- The constantPendingMessageLimitStrategy is used to preventslow topic consumers to block producers and affect other consumersby limiting the number of messages that are retainedFor more information, see:http://activemq.apache.org/slow-consumer-handling.html--><pendingMessageLimitStrategy><constantPendingMessageLimitStrategy limit="1000"/></pendingMessageLimitStrategy></policyEntry></policyEntries></policyMap></destinationPolicy><!--The managementContext is used to configure how ActiveMQ is exposed inJMX. By default, ActiveMQ uses the MBean server that is started bythe JVM. For more information, see:http://activemq.apache.org/jmx.html--><managementContext><managementContext createConnector="false"/></managementContext><!--Configure message persistence for the broker. The default persistencemechanism is the KahaDB store (identified by the kahaDB tag).For more information, see:http://activemq.apache.org/persistence.html--><persistenceAdapter><kahaDB directory="${activemq.data}/kahadb"/></persistenceAdapter><!--The systemUsage controls the maximum amount of space the broker willuse before disabling caching and/or slowing down producers. For more information, see:http://activemq.apache.org/producer-flow-control.html--><systemUsage><systemUsage><memoryUsage><memoryUsage percentOfJvmHeap="70" /></memoryUsage><storeUsage><storeUsage limit="100 gb"/></storeUsage><tempUsage><tempUsage limit="50 gb"/></tempUsage></systemUsage></systemUsage><!--The transport connectors expose ActiveMQ over a given protocol toclients and other brokers. For more information, see:http://activemq.apache.org/configuring-transports.html--><transportConnectors><!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB --><transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/><transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/><transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/><transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/><transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/></transportConnectors><!-- destroy the spring context on shutdown to stop jetty --><shutdownHooks><bean xmlns="http://www.springframework.org/schema/beans" class="org.apache.activemq.hooks.SpringContextHook" /></shutdownHooks></broker><!--Enable web consoles, REST and Ajax APIs and demosThe web consoles requires by default login, you can disable this in the jetty.xml fileTake a look at ${ACTIVEMQ_HOME}/conf/jetty.xml for more details--><import resource="jetty.xml"/></beans>
<!-- END SNIPPET: example -->
天行健,君子以自强不息;地势坤,君子以厚德载物
相关文章:
ActiveMQ配置初探
文章目录 配置wrapper相关配置wrapper是干什么用的MQ的运行内存修改【需修改】修改内容题外话 wrapper.log配置【需修改】引起的问题优化方式 activemq.xml相关配置官网介绍配置管理后台的认证授权【建议修改】配置broker【根据自己需求更改】配置允许jmx监控关闭消息通知持久化…...
【官方中文文档】Mybatis-Spring #示例代码
示例代码 提示 查看 JPetstore 6 demo 了解如何在完整的 Web 应用服务器上使用 Spring。 您可以在 MyBatis-Spring 的 代码仓库 中查看示例代码: 所有示例都能在 JUnit 5 下运行。 示例代码演示了事务服务从数据访问层获取域对象的典型设计。 FooService.java …...
python二级例题
请编写程序,生成随机密码。具体要求如下: (1)使用 rand…...
【java】【项目实战】[外卖九]项目优化(缓存)
目录 一、问题说明 二、环境搭建 2.1 Git管理代码 2.1.1 创建本地仓库 2.1.2 创建远程仓库 2.1.3 创建分支--》推送到远程仓库 2.2 maven坐标 2.3 配置文件application.yml 2.4 配置类RedisConfig 三、缓存短信验证码 3.1 实现思路 3.2 代码改造 3.2.1 UserContro…...
Scala集合常用函数与集合计算简单函数,高级计算函数Map和Reduce等
Scala集合常用函数与集合计算简单函数 1.Scala集合常用函数 基本属性和常用操作 1.常用函数: (1) 获取集合长度(2) 获取集合大小(3) 循环遍历(4) 迭代器(…...
You must install at least one postgresql-client-<version> package
使用主机上的映射端口来连接到 PostgreSQL 数据库。例如,使用以下命令连接到数据库: psql -h localhost -p 5432 -U postgres出现下面的问题: 分析: 如果您在运行 psql 命令时遇到错误消息 You must install at least one pos…...
爬虫源码---爬取自己想要看的小说
前言: 小说作为在自己空闲时间下的消遣工具,对我们打发空闲时间很有帮助,而我们在网站上面浏览小说时会被广告和其他一些东西影响我们的观看体验,而这时我们就可以利用爬虫将我们想要观看的小说下载下来,这样就不会担…...
【AGC】云数据库API9开发问题汇总
【问题描述】 云数据库HarmonyOS API9 SDK已经推出了一段时间了,下面为大家汇总一些在集成使用中遇到的问题和解决方案。 【问题分析】 1. 报错信息:数据库初始化失败:{“message”:“The object type list and permission …...
ASP.NET Core IOC容器
//IOC容器支持依赖注入{ServiceCollection serviceDescriptors new ServiceCollection();serviceDescriptors.AddTransient<IMicrophone, Microphone>();serviceDescriptors.AddTransient<IPower, Power>();serviceDescriptors.AddTransient<IHeadphone, Headp…...
入门力扣自学笔记277 C++ (题目编号:42)(动态规划)
42. 接雨水 题目: 给定 n 个非负整数表示每个宽度为 1 的柱子的高度图,计算按此排列的柱子,下雨之后能接多少雨水。 示例 1: 输入:height [0,1,0,2,1,0,1,3,2,1,2,1] 输出:6 解释:上面是由数组…...
SwiftUI实现iPad多任务分屏
1. 概述 iPadOS引入了多任务分屏功能,使用户能够同时在一个屏幕上使用多个应用程序。这为用户提供了更高效的工作环境,可以在同一时间处理多个任务。 iPad多任务分屏有两种常见的模式:1/2分屏和Slide Over(滑动覆盖)…...
maven依赖,继承
依赖的范围 compile引入的依赖 对main目录下的代码有没有效,main目录下的代码能不能用compile引入的依赖中的类等 以test引入的依赖,在main中是否可以使用 provided(已提供),有了就不要带到服务器上,打包…...
仿`gRPC`功能实现像调用本地方法一样调用其他服务器方法
文章目录 仿gRPC功能实现像调用本地方法一样调用其他服务器方法 简介单体架构微服务架构RPCgPRC gRPC交互逻辑服务端逻辑客户端逻辑示例图 原生实现仿gRPC框架编写客户端方法编写服务端方法综合演示 仿 gRPC功能实现像调用本地方法一样调用其他服务器方法 简介 在介绍gRPC简介…...
分布式环境下的数据同步
一般而言elasticsearch负责搜索(查询),而sql数据负责记录(增删改),elasticsearch中的数据来自于sql数据库,因此sql数据发生改变时,elasticsearch也必须跟着改变,这个就是…...
无涯教程-Flutter - 数据库
SQLite" class"css-1occaib">SQLite数据库是基于事实和标准SQL的嵌入式数据库引擎,它是小型且经过时间考验的数据库引擎,sqflite软件包提供了许多函数,可以有效地与SQLite数据库一起使用,它提供了操作SQLite数据…...
算法笔记:平衡二叉树
1 介绍 平衡二叉树(AVL树)是一种特殊的二叉搜索树(BST),它自动确保树保持低高度,以便实现各种基本操作(如添加、删除和查找)的高效性能。 ——>时间都维持在了O(logN)它是一棵空…...
redis 通用命令
目录 通用命令是什么 SET & GET keys EXISTS DEL EXPIRE TTL redis 的过期策略 定时器策略 基于优先级队列定时器 基于时间轮的定时器 TYPE 通过 redis 客户端和 redis 服务器交互。 所以需要使用 redis 的命令,但是 redis 的命令非常多。 通用命令…...
Pycharm配置及使用Git教程
文章目录 1. 安装PyCharm2. 安装Git3. 在PyCharm中配置Git插件4. 连接远程Gtilab仓库5. Clone项目代码6. 将本地文件提交到远程仓库6.1 git add6.2 git commit6.3 git push6.4 git pull 平时习惯在windows下开发,但是我们又需要实时将远方仓库的代码clone到本地&…...
CSS transition 过渡
1 前言 水平居中、垂直居中是前端面试百问不厌的问题。 其实现方案也是多种多样,常叫人头昏眼花。 水平方向可以认为是内联方向,垂直方向认为是块级方向。 下面介绍一些常见的方法。 2 内联元素的水平垂直居中 首先,常见内联元素有&…...
Unity中Shader的UV扭曲效果的实现
文章目录 前言一、实现的思路1、在属性面板暴露一个 扭曲贴图的属性2、在片元结构体中,新增一个float2类型的变量,用于独立存储将用于扭曲的纹理的信息3、在顶点着色器中,根据需要使用TRANSFORM_TEX对Tilling 和 Offset 插值;以及…...
Automotive 添加一个特权APP
Automotive 添加一个特权APP platform: android-13.0.0_r32 一. 添加一个自定义空调的app为例 路径:packages/apps/Car/MyHvac app内容可以自己定义,目录结构如下: 1.1 Android.bp package {default_applicable_licenses: ["Andr…...
自定义TimeLine
自定义TimeLine 什么是TimeLineData(数据)Clip(片段)Track(轨道)Mixer(混合) 什么是TimeLine 在 Unity 中,TimeLine(时间轴)是一种用于创建和管理…...
如何使用SQL系列 之 如何在SQL中使用WHERE条件语句
引言 在结构化查询语言 (SQL)语句中,WHERE子句限制了给定操作会影响哪些行。它们通过定义特定的条件(称为搜索条件)来实现这一点,每一行都必须满足这些条件才能受到操作的影响。 本指南将介绍WHERE子句中使用的通用语法。它还将概述如何在单个WHERE子句…...
leetcode:1941. 检查是否所有字符出现次数相同(python3解法)
难度:简单 给你一个字符串 s ,如果 s 是一个 好 字符串,请你返回 true ,否则请返回 false 。 如果 s 中出现过的 所有 字符的出现次数 相同 ,那么我们称字符串 s 是 好 字符串。 示例 1: 输入:s…...
Echarts 各种点击事件监听
目录 一、鼠标事件1.1、左击1.2、双击1.3、右击1.4、右键双击1.5、中轴滚动二、时间轴2.1、时间轴监听三、拖动3.1、拖动事件一、鼠标事件 1.1、左击 chart.on(click, function(params)...
《智能网联汽车自动驾驶功能测试规程》
一、 编制背景 2018 年4 月12 日,工业和信息化部、公安部、交通运输部联合发布《智能网联汽车道路测试管理规范(试行)》(以下简称《管理规范》),对智能网联汽车道路测试申请、审核、管理以及测试主体、测试驾驶人和测试车辆要求等…...
NVIDIA CUDA Win10安装步骤
前言 windows10 版本安装 CUDA ,首先需要下载两个安装包 CUDA toolkit(toolkit就是指工具包)cuDNN 1. 安装前准备 在安装CUDA之前,需要完成以下准备工作: 确认你的显卡已经正确安装,在设备管理器中可以看…...
Elasticsearch、Kibana以及Java操作ES 的快速使用
docker 安装elastic search 、 kibana(可视化管理elastic search) docker pull elasticsearch:7.12.1 docker pull kibana:7.12.1创建docker自定义网络 docker自定义网络可以使得容器之间使用容器名网络互连,默认的网络不会有这功能。 一定…...
逐鹿人形机器人,百度、腾讯、小米卷起来
长期不温不火的人形机器人产业迎来新风口,技术显著提升、新品层出不穷、资本投资态度也逐渐好转。 8月18日,2023世界机器人大会博览会正式开放,全面展示了机器人行业的新技术、新产品和新应用。据悉,此次展会展览总面积达4.5万平…...
AndroidStudio推荐下载和配置
1、推荐下载链接 Download Android Studio & App Tools - Android Developers 2、gradle配置案例 // Top-level build file where you can add configuration options common to all sub-projects/modules.buildscript {repositories {maven { url https://maven.aliyun.…...
赫章网站建设/网站ui设计
在CSS中,与媒体相关的样式定义是从CSS2.1开始的。CSS2.1中定义了各种媒体类型,包括显示器、便携设备、电视机,等等。 CSS3中加入了Media Queries模块,该模块中允许添加媒体查询表达式,用以指定媒体类型࿰…...
检测ai写作的网站/常见的网络直接营销有哪些
原文:xshell登陆Win10 Linux子系统版权声明:转载请注明出处 https://blog.csdn.net/anychenp/article/details/78922320 修改端口 cd /etc/ssh #备份 sudo cp sshd_config sshd_config.bak sudo vim sshd_config 修改sshd_config Port 2233 #修改端口 ListenAddres…...
ftp服务器搭建设置网站信息/企业网站模板图片
收集一些有用的博客,造福全人类: http://fullstack.info/ 不知道是谁,好像很吊的样子http://substack.net/ substack nodejs大神,贡献了几百个nodejs模块http://blog.izs.me/ nodejs巨屌http://lucumr.pocoo.org/ Flask作者http:…...
承德做网站/友情链接英文
1.首先安装好LAMP这一个组合,在安装的过程中重点关注PHP的安装./configure --prefix/usr/local/php5 --enable-mbstring--with-apxs2/usr/local/apache2/bin/apxs--with-mysql/usr/local/mysql--with-config-file-path/usr/local/php5--with-zlibmake ;make install…...
wordpress选项卡插件/全网搜索
一 checkinstall 简介,及所需环境 1 Checkinstall 是一个能从 tar.gz类的源代码自动生成RPM/Debian或Slackware安装包的程序。这样使你能用几乎所有的 tar.gz 类的源代码生成“干净”的安装或者卸载包。 2 OS: rhel 6.4 x86_64 3 chechinstal…...
品牌网站设计视频教程/百度广告价格
1、首先安装iptables(一般情况,ubuntu默认是安装好的) sudo apt-get update sudo apt-get install iptables 2、安装完成后,开放指定端口,如8080,使用一下命令 sudo iptables -I INPUT -p tcp --dport …...