我正在阅读以下新功能:http://www.javaworld.com/article/2078836/java-se/love-and-hate-for-java-8.html
我看到了下面的例子:
使用匿名类:
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
System.out.println("Action Detected");
}
});
Run Code Online (Sandbox Code Playgroud)
使用Lambda:
button.addActionListener(e -> {
System.out.println("Action Detected");
});
Run Code Online (Sandbox Code Playgroud)
MouseListener如果他们想在匿名类中实现多个方法,有人会做什么,例如:
public void mousePressed(MouseEvent e) {
saySomething("Mouse pressed; # of clicks: "
+ e.getClickCount(), e);
}
public void mouseReleased(MouseEvent e) {
saySomething("Mouse released; # of clicks: "
+ e.getClickCount(), e);
}
Run Code Online (Sandbox Code Playgroud)
... 等等?
org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [referencedata.ABDeadlineType] to type [referencedata.DeadlineType]
at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:324)
at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:206)
at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:187)
at org.springframework.data.repository.query.ResultProcessor$ProjectingConverter.convert(ResultProcessor.java:256)
at org.springframework.data.repository.query.ResultProcessor$ChainingConverter$1.convert(ResultProcessor.java:201)
at org.springframework.data.repository.query.ResultProcessor$ChainingConverter.convert(ResultProcessor.java:212)
at org.springframework.data.repository.query.ResultProcessor.processResult(ResultProcessor.java:149)
at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:121)
at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:106)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:483)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:461)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:56)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:133)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:57)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
at com.sun.proxy.$Proxy143.findAllSummarizedBy(Unknown Source)
at
Run Code Online (Sandbox Code Playgroud)
DeadlineType
@Data
public class DeadlineType extends DefaultIdAndText …Run Code Online (Sandbox Code Playgroud) 我正在阅读有关使用MEMORY ENGINE表格的表格(存储在ram中的表格).
是否可以使用CREATE TABLE AS SELECT语法,但是创建了表格MEMORY ENGINE吗?
MEMORY表的大小是否有限制?可以创建一个MEMORY表,它是一个pysical 1.5 GB表的副本?
那么,你将如何进行转换
String csv = "11,00,33,66,44,33,22,00,11";
Run Code Online (Sandbox Code Playgroud)
以最快最优化的方式使用hashset.
这是一个用户ID列表.
我运行了通过测试程序提供的所有答案,其中每个方法被调用500,000次以获得更大的CSV字符串.该测试连续执行5次(如果程序启动减慢了初始方法),我得到以下毫秒(ms):
Method One Liner-> 6597
Method Split&Iterate-> 6090
Method Tokenizer-> 4306
------------------------------------------------
Method One Liner-> 6321
Method Split&Iterate-> 6012
Method Tokenizer-> 4227
------------------------------------------------
Method One Liner-> 6375
Method Split&Iterate-> 5986
Method Tokenizer-> 4340
------------------------------------------------
Method One Liner-> 6283
Method Split&Iterate-> 5974
Method Tokenizer-> 4302
------------------------------------------------
Method One Liner-> 6343
Method Split&Iterate-> 5920
Method Tokenizer-> 4227
------------------------------------------------
static void method0_oneLiner() {
for (int j = 0; j < TEST_TIMES; j++) {
Set<String> hashSet …Run Code Online (Sandbox Code Playgroud) 我有以下课程:
@Builder @NoArgsConstructor
public class ConsultationPointOfContact {
private String fullName;
private String phoneNumber;
private String userLogin;
}
Run Code Online (Sandbox Code Playgroud)
当@Builder注释存在时,它会导致问题@NoArgsConstructor.
我收到错误:
Error:(11, 1) java: constructor ConsultationPointOfContact in class models.ConsultationPointOfContact cannot be applied to given types;
required: no arguments
found: java.lang.String,java.lang.String,java.lang.String
reason: actual and formal argument lists differ in length
Run Code Online (Sandbox Code Playgroud) 因此,我注意到jhipster项目的gradle文件中的以下行:
annotationProcessor ("org.springframework.boot:spring-boot-configuration-processor") {
exclude group: 'com.vaadin.external.google', module: 'android-json'
}
Run Code Online (Sandbox Code Playgroud)
我们还对另一个项目在Maven中使用了相同的配置来解决以下问题:不排除Maven瞬态依赖项(库/ jar vaadin json)
现在我有以下问题:
我最近使用netflix假装和功能区非常有用.
一个例子是:
@FeignClient(name = "ldap-proxy")
public interface LdapProxyClient {
@RequestMapping(path = "/ldap-proxy/v1/users/{userNameOrEMail}", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
LdapUser search(@PathVariable("userNameOrEMail") String userNameOrEMail);
}
Run Code Online (Sandbox Code Playgroud)
但是,在某些时候,我认为不必手动编写所有这些定义(对于现有的Web服务),我应该看看是否存在工具.
我偶然发现了https://github.com/swagger-api/swagger-codegen一些客户端生成的例子,例如https://github.com/swagger-api/swagger-codegen/tree/master/samples/client/petstore/java/feign.
但是,一旦我仔细查看了进口,我注意到以下情况:
import feign.Feign;
另一方面,Netflix的开源解决方案有包名:
org.springframework.cloud.netflix.feign.
另外,我注意到两者都使用功能区(如果可用),但Netflix的表示法更加清晰,后台发生了很多事情.例如,@FeignClient注释类javadoc声明:
- 接口的注释声明应该*创建具有该接口的REST客户端(例如,用于自动装配到另一个组件中).如果功能区可用,它将*用于对后端请求进行负载平衡,并且可以使用
@RibbonClient与feign客户端具有相同名称(即值)的a来配置负载均衡器.
但是在Feign.feign文档中(https://github.com/OpenFeign/feign),我看到:
RibbonClient覆盖了Feign客户端的URL解析,添加了Ribbon提供的智能路由和弹性功能.
集成要求您将功能区客户端名称作为URL的主机部分传递,例如myAppProd.
> MyService api =
> Feign.builder().client(RibbonClient.create()).target(MyService.class,
> "https://myAppProd");
Run Code Online (Sandbox Code Playgroud)
它们是完全不同的项目,没有关系,或者netflix只是分叉/利用OpenFeign并将其修改为在其集成云解决方案中?从本质上讲,netflix是否只是从开源项目中获取并集成了Discovery,Ribbon和feign等不同技术?
我注意到以下代码在使用java spec 1.7在eclipse中编译时起作用,但不适用于1.6.
HashMap<String, String> hashMap = new HashMap<>();
Run Code Online (Sandbox Code Playgroud)
我想要一个解释但是这个语法以及为什么它适用于1.7.
我想记录实际的JSON字段本身代表什么.
我已经记录了GET语句和参数,但这并没有为用户提供完整的文档.
因此,在下面的示例中,我将如何添加有关"OtherFields"的注释.这支持吗?或者我是否需要在其他地方制作配套文件.
## View Applications [/cat{?sort}{&order}{&page}]
### List all Applications
### Get List of Applications [GET]
+ Parameters
+ sort (optional, string) ... `sort` parameter is used to specify which criteria to use for sorting. One of the following strings may be used:
`"NAME",
"RATING", "QUALITY" ,
"RISKLEVEL", `
+ order (optional, string) ... `order` parameter is used to specify which order to use if sorting is used. One of the following strings may be used:
`"ASC",
"DESC"`
+ …Run Code Online (Sandbox Code Playgroud) 基本上我想从 Postgres 中的 SQL 文件执行一个 SQL 文件。
mysql 的类似问题:是否可以从另一个 sql 脚本中的存储过程调用 sql 脚本?
为什么?
因为我在一个项目中有 2 个数据文件,我希望有一行可以被注释/取消注释以加载第二个文件。
说明: 我想从 A.SQL 调用 B.SQL
说明 2: 这是针对使用 hibernate 从初始 SQL 文件 (A.SQL) 创建数据库的 Spring 项目。
经过进一步思考,似乎我可能不得不从 java/string/hibernate 处理这个问题。
下面是配置文件:
spring.datasource.url=jdbc:postgresql://localhost:5432/dbname
spring.datasource.username=postgres
spring.datasource.password=root
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.data=classpath:db/migration/postgres/data.sql
spring.jpa.hibernate.ddl-auto=create
Run Code Online (Sandbox Code Playgroud)