添加后无法构建项目
compile 'com.android.support:design:24.2.0'
Run Code Online (Sandbox Code Playgroud)
继续发出以下错误:
似乎,问题是支持矢量drawables.在某处某些属性被添加两次.
例如,内置的values.xml文件包含:
<declare-styleable name="AppBarLayout_LayoutParams"><attr name="layout_scrollFlags"><flag name="scroll" value="0x1"/><flag name="exitUntilCollapsed" value="0x2"/><flag name="enterAlways" value="0x4"/><flag name="enterAlwaysCollapsed" value="0x8"/></attr><attr format="reference" name="layout_scrollInterpolator"/></declare-styleable>
Run Code Online (Sandbox Code Playgroud)
和
<declare-styleable name="AppBarLayout_Layout"><attr name="layout_scrollFlags">
<flag name="scroll" value="0x1"/>
<flag name="exitUntilCollapsed" value="0x2"/>
<flag name="enterAlways" value="0x4"/>
<flag name="enterAlwaysCollapsed" value="0x8"/>
<flag name="snap" value="0x10"/>
Run Code Online (Sandbox Code Playgroud)
我已将此添加到gradle文件中:
compile 'com.android.support:cardview-v7:24.2.0' + '@aar'
compile 'com.android.support:recyclerview-v7:24.2.0' + '@aar'
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:design:24.2.0'
Run Code Online (Sandbox Code Playgroud) 我已使用以下配置配置tomcat:
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
maxThreads="500"
maxConnections="20000"
acceptCount="150"
etc... />
Run Code Online (Sandbox Code Playgroud)
AJP连接器的数字相同,maxThreads=500和acceptCount="150".
它在大多数情况下工作正常,但在高峰时段,当我的请求比平时多得多时,响应时间太长.有时超过15秒,极少数情况下是timeOut.它可能看起来没问题,因为maxThreads=500我有几千个请求,但是,在服务器状态我看到:
最大线程数:500当前线程数:17当前线程忙:1保持活动套接字计数:1
currentThreadCount到目前为止我看到的最大数量是27.如果有这么多的连接,tomcat是否应该创建更多线程(最多500个)来更快地响应?
那么,我做错了什么?我错过了什么?我有2个核心CPU(高峰时段最大使用量~10%)和2GB RAM(最大使用率60%).
关于Web应用程序的简短信息:通常,每个用户每个会话至少发出2个请求:静态JSON响应和1个数据库查询.在高峰时间,我有15-20k活跃用户,但我不知道每秒有多少请求.但是,响应缓慢从5k活跃用户开始.
我还增加了app属性上的最大活动连接数,但性能没有变化,我当前的application.properties:
spring.jpa.hibernate.ddl-auto=update
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/database_name
spring.datasource.username=$username$
spring.datasource.password=$password$
spring.datasource.tomcat.max-active=200
spring.datasource.tomcat.max-wait=10000
spring.datasource.tomcat.max-idle=50
spring.datasource.tomcat.min-idle=10
spring.datasource.tomcat.initial-size=10
Run Code Online (Sandbox Code Playgroud)
更新
我将默认JDBC连接池更改Hikari为以下配置并启用了jta,但是,在高峰时间没有任何差异:
spring.jta.enabled=true
spring.datasource.hikari.maximum-pool-size=125
spring.datasource.hikari.minimum-idle=5
Run Code Online (Sandbox Code Playgroud)
I am adding database query below. Results of the query later added into another object and returned as ResponseBody.
@Query("select new ObjectClass(s.id, s.a, s.b, s.c") from TableName s " + …Run Code Online (Sandbox Code Playgroud) 是否可以在 Room Query 中使用预定义的字符串?例如:
@Query("delete from Bookmarks where listName != Constants.SOME_LIST_NAME")
void deleteAllBookmarks();
Run Code Online (Sandbox Code Playgroud)
为了清楚起见,我不想将它作为参数传递:
@Query("delete from Bookmarks where listName != :listName")
void deleteAllBookmarks(String listName);
Run Code Online (Sandbox Code Playgroud)
我不想对其进行硬编码(它在不止一个地方使用):
@Query("delete from Bookmarks where listName != 'MyList'")
void deleteAllBookmarks();
Run Code Online (Sandbox Code Playgroud) 大部分代码都是从旧项目中复制的,只不过这次我使用 Gradle 而不是 maven。
当我通过 IntelliJ 在本地计算机上运行该项目时,会创建新表并且一切正常。
但是,当我将其上传到tomcat时,我在数据库上看不到表。当我检查端点并尝试保存新数据时,这是可能的,并且保存后我可以访问它们。
当项目在tomcat中时,数据是可以访问的。一旦我重新加载/取消部署并再次部署,数据就会丢失,并且我无法通过服务访问数据。直到我保存新数据。也许它与“内存数据库”有关。
应用程序属性:
spring.jpa.hibernate.ddl-auto=update
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/database_name?autoReconnect=true&useSSL=false&createDatabaseIfNotExist=true
spring.datasource.username=username
spring.datasource.password=password
spring.jta.enabled=true
spring.datasource.hikari.minimum-idle=10
spring.datasource.hikari.maximum-pool-size=300
spring.datasource.hikari.idleTimeout=30000
spring.datasource.hikari.maxLifetime=2000000
spring.datasource.hikari.connectionTimeout=30000
Run Code Online (Sandbox Code Playgroud)
我检查了几个小时也没找到问题所在。我登录服务器并检查 Catalina 日志,没有错误消息。它们或多或少是相同的,直到 IntelliJ 创建表时,它在 Catalina.out 上丢失了。
org.hibernate.SQL : create table table_name ...
Run Code Online (Sandbox Code Playgroud)
主类位于包 xy 中,实体位于 xydatabase.tables 中。
从 catalina.out 登录:
30-May-2021 23:15:40.921 INFO [ajp-nio-8009-exec-356] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in …Run Code Online (Sandbox Code Playgroud)