使用 Eclipse Luna Service Release 2 (4.4.2) Build id: 20150219-0600 在 Tomcat v8.0 中运行的 Java Web 应用程序(黄金副本)
在几天的时间里,我已经多次重新启动了 Eclipse 及其调试器,这种情况已经持续发生了几天,所以这不是随机的侥幸:
在我的代码中,Eclipse 调试器点击注释行,并跳过一些实际的代码行。有些东西告诉我实际的代码没有被读取以进行调试。可能发生什么事?
以下从JPA查询获取Spring Data Projection的方法对我不起作用:
我的桌子:
LOOKUP_T
id description display_order_num
------------------------------------
1 Category #1 1
2 Category #2 2
Run Code Online (Sandbox Code Playgroud)
ACTIVITIES_T(activity_category_id映射到LOOKUP_T.id)
id activity_category_id activity_title
---------------------------------------
1 2 Sleeping
2 2 Eating
3 2 Travel
Run Code Online (Sandbox Code Playgroud)
Spring Data DAO接口从此连接获取某些字段:
@Repository
public interface ActivitiesDAO extends JpaRepository<ActivitiesT, Integer> {
@Query("select a.activityTitle, l.description as category, " +
"l.displayOrderNum as categoryDisplayOrderNum " +
"from ActivitiesT a, LookupT l " +
"where a.lookupT.id = l.id order by l.displayOrderNum asc ")
public List<MySpringDataProjection> findCustom();
}
Run Code Online (Sandbox Code Playgroud)
Spring Data Projection Model接口:
public …Run Code Online (Sandbox Code Playgroud) 我在使用 Bootstrap-Table 插件时遇到问题:https : //github.com/wenzhixin/bootstrap-table
我需要隐藏的表中有一个隐藏的 ID 列。但我做不到
<th data-field="id" data-visible="false">ID</th>
Run Code Online (Sandbox Code Playgroud)
因为这会将它从 DOM 中删除。我需要将 ID 保留在 DOM 中,因为它用于表单提交。它只需要隐藏。
这也不起作用,我的样式丢失并且该列不存在:
<th data-field="id" style="display:none;>ID</th>
Run Code Online (Sandbox Code Playgroud)
我什至不能使用 jQuery 手动隐藏列!换句话说,我在 onPostBody 之后尝试了以下操作,但它也从未触发过!
<table id="delegateTable" data-toggle="table" data-url="delegates.action"
data-response-handler="delegatesResponseHandler">
<thead>
<tr>
<th data-field="id">ID</th>
<th data-field="delegate" style="width:10%">Delegate</th>
</thead>
</table>
Run Code Online (Sandbox Code Playgroud)
jQuery 文档 OnReady:
$(document).ready(function() {
// Hide column
$('#delegateTable').bootstrapTable({
onPostBody : function() {
$('#delegateTable td:nth-child(0), th:nth-child(0)').hide();
alert('column hidden');
}
});
Run Code Online (Sandbox Code Playgroud)
它甚至从未达到过 onPostBody。
我有一个List<DataBean>bean定义如下,
private int id;
private int activityId;
private String info;
private int answerCode;
private String otherData;
Run Code Online (Sandbox Code Playgroud)
还有另一个带有不同 bean 的 List List<Answer>,其 bean 如下所示:
private int id;
private int code;
Run Code Online (Sandbox Code Playgroud)
我需要找到所有的答案List<Answer>,其code包含在列List<DataBean>.answerCode。
例子:
List<DataBean> 包含
id activityId info answerCode
1 1 .. 144
1 1 .. 153
1 2 .. 160
1 3 .. 177
Run Code Online (Sandbox Code Playgroud)
List<Answer> 包含
id code
--------
1 160
2 161
Run Code Online (Sandbox Code Playgroud)
因此,我的结果List<Answer>只有一个: 1 160.
(Postgres)
我不清楚以下内容:我正在选择各种字段,其中STUDY_T可能是带有聚合函数的子选择。我正在检索的一个独立字段是 LOOKUP_T join, lookupStudyType.description,它与任何聚合函数都不相关。但我收到错误
ERROR: column "lookupstudytype.description" must appear in the GROUP BY clause or be used in an aggregate function
LINE 3: lookupStudyType.description AS studyTypeDescription,...
Run Code Online (Sandbox Code Playgroud)
为什么我不仅需要分组,s.id还需要分组lookupStudyType.description(而其他s.分组不是必需的)?
SELECT
s.id AS id,
lookupStudyType.description AS studyTypeDescription,
s.name AS name,
s.abbreviation AS abbreviation,
s.start_date AS startDate,
s.end_date AS endDate,
(SELECT COUNT(r.id)
FILTER
(WHERE r.status_id IN (76, 77) )) AS recallCount,
(SELECT COUNT(DISTINCT sp.id)) AS participantCount,
(SELECT MAX(r.created_date)
FILTER
(WHERE r.status_id IN (76,77) )) …Run Code Online (Sandbox Code Playgroud) 我有一个初始数组,array1其中包含 30 个元素,需要创建一个array2包含 中元素 0-14 的新数组array1。
我用作IntStream数组索引的映射器。但以下给出了错误:
Object[] array2 = IntStream.range(0,14).map(x -> (Object)array1[x]).toArray(Object[]::new);
Run Code Online (Sandbox Code Playgroud)
错误(Object)array1[x]:
The type of the expression must be an array type but it resolved to List<Object[]>
Run Code Online (Sandbox Code Playgroud) 我需要检查表A中的值组合是否存在于另一个表B中指定的相应列集中.
到目前为止,我正在这样做,这似乎并不优雅或高效:
select * from table1 where
colX_table_1 NOT IN (select colX_table_2 from table2)
and
colY_table_1 NOT IN (select colY_table_2 from table2)
Run Code Online (Sandbox Code Playgroud)
是否有更好/更快的方法来执行此组合检查(colX_table_1,colY_table_1) - >(colX_table_2,colY_table_2)?
我们只允许(1)9位数字或(2)10位数字(最后4位数字前带有破折号)作为美国邮政编码。
以下正则表达式给出了编译错误:
private static final String USZIPCODE_MATCH_FORMAT_REGEXP = "^\d{5}[\\-]?\d{4}$";
Invalid escape sequence
Run Code Online (Sandbox Code Playgroud) HandlebarsJS 不支持字符串相等('=='),所以我必须编写自己的助手,但这个答案不清楚:
Handlebars.registerHelper('if_eq', function(a, b, opts) {
if(a == b) // Or === depending on your needs
return opts.fn(this);
else
return opts.inverse(this);
});
Run Code Online (Sandbox Code Playgroud)
然后调整您的模板:
{{#if_eq this "some message"}}
...
{{else}}
...
{{/if_eq}}
Run Code Online (Sandbox Code Playgroud)
1)他为什么做{{#if_eq ..}}而不是{{#if if_eq .. }}?
2)我还需要做ELSE-IF,这是自 Handlebars 3.0.0(我有 4.0)以来支持的。但是使用他的符号,我将无法做到{{#elseif_eq}}没有这样的表达。我将如何使用此自定义帮助程序实现 ELSE-IF?
我必须升级 Spring Boot 依赖项2.7.5 --> 3.0.2:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.2</version>
<relativePath />
</parent>
Run Code Online (Sandbox Code Playgroud)
当前引用了相对较新的pom.xml版本HttpClient4.5.3 :
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.3</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
该代码使用的org.apache.http类现在在 Maven Build 上产生以下错误:
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.ssl.SSLContextBuilder;
Run Code Online (Sandbox Code Playgroud)
--> 不兼容的类型:org.apache.http.impl.client.CloseableHttpClient 无法转换为 org.apache.hc.client5.http.classic.HttpClient
为了解决此错误,我将所有出现的替换org.apache.http为https://hc.apache.org/httpcomponents-client-5.2.x/migration-guide/migration-to-classic.html:org.apache.hc.httpclient5
import org.apache.hc.httpclient5.conn.ssl.SSLConnectionSocketFactory;
import org.apache.hc.httpclient5.conn.ssl.TrustSelfSignedStrategy;
import org.apache.hc.httpclient5.impl.client.CloseableHttpClient;
import org.apache.hc.httpclient5.impl.client.HttpClients;
import org.apache.hc.httpclient5.ssl.SSLContextBuilder;
Run Code Online (Sandbox Code Playgroud)
但现在错误是
包 org.apache.hc.httpclient5.conn.ssl 不存在。它无法解析 HC5 包。有小费吗?

注意:我还尝试将 HttpClient 依赖项替换为新的httpclient5依赖项,但这是相同的错误:
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<version>5.2.1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud) java apache-httpclient-4.x spring-boot apache-httpclient-5.x
java ×4
sql ×2
debugging ×1
eclipse ×1
jpa ×1
jquery ×1
postgresql ×1
regex ×1
select ×1
spring ×1
spring-boot ×1
spring-data ×1
templates ×1