如何@see正确使用javadoc?
我的目的是使用抽象方法创建一个抽象类.这些方法有javadoc注释.现在,如果我扩展抽象类,我会覆盖方法并想要使用@see.
但对于所有的参数,可以如用于return该@see链接似乎并没有工作.Eclipse仍抱怨expected @return tag.
那我该怎么用?
public abstract class MyBase {
protected abstract void myFunc();
}
class MyImpl extends MyBase {
/**
* @see MyBase#myFunc()
*/
@Override
protected void myFunc() { .. }
}
Run Code Online (Sandbox Code Playgroud) 我的数据库中有一些日期条目.什么是最好的?:
order by.collection.sort左右对它们进行排序?谢谢
我想在spring-data中使用方法名称的sql select.
选择应按价格排序.
@Entity
public class Product {
int name;
BigDecimal price;
}
interface ProductRepository extends CrudRepository<Product, Long> {
Product findFirstByNameOrderByPriceAsc(String name);
}
Run Code Online (Sandbox Code Playgroud)
结果:
org.springframework.dao.IncorrectResultSizeDataAccessException: result returns more than one elements; nested exception is javax.persistence.NonUniqueResultException: result returns more than one elements
Run Code Online (Sandbox Code Playgroud)
为什么?我正是findFirst()因为这个原因才使用该方法才能获得最佳结果,如果找到多个...
如何最好地检查字符串输入是否是用于编码的有效java变量?我敢肯定,我不是第一个愿意这样做的人.但也许我错过了正确的关键字来找到有用的东西.
最好的可能是RegEx,它检查:
以一封信开头
然后可以包含数字,字母
可以包含一些特殊字符,比如'_'(哪个?)
如何使用hibernate注释来验证枚举成员字段?以下不起作用:
enum UserRole {
USER, ADMIN;
}
class User {
@NotBlank //HV000030: No validator could be found for type: UserRole.
UserRole userRole;
}
Run Code Online (Sandbox Code Playgroud) 我RollingFileAppender习惯于正常的log4j.现在我正在切换log4j2,并且无法让appender工作.
File下面的appender按预期工作.但RollingFile永远不会创建日志记录文件.为什么?
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<File name="FILE" fileName="c:/logs.log">
<PatternLayout pattern="%d %p %c: %m%n" />
</File>
<RollingFile name="ROLLING" fileName="c:/logsroll.log">
<PatternLayout pattern="%d %p %c: %m%n"/>
<Policies>
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="0.001 MB"/>
</Policies>
<DefaultRolloverStrategy max="10"/>
</RollingFile>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="FILE" />
<AppenderRef ref="ROLLING" />
</Root>
</Loggers>
</Configuration>
Run Code Online (Sandbox Code Playgroud) 是否可以使用基于注释的配置(@Bean等)实现相同的bean继承?
<bean id="inheritedTestBean" abstract="true"
class="org.springframework.beans.TestBean">
<property name="name" value="parent"/>
<property name="age" value="1"/>
</bean>
<bean id="inheritsWithDifferentClass"
class="org.springframework.beans.DerivedTestBean"
parent="inheritedTestBean" init-method="initialize">
<property name="name" value="override"/>
<!-- the age property value of 1 will be inherited from parent -->
</bean>
Run Code Online (Sandbox Code Playgroud)
在控制器中,如果有一个跟踪分页表的索引(从0开始)的变量:
var page {
pageNumber: 0;
}
Run Code Online (Sandbox Code Playgroud)
问题:如何pageNumber在html中显示此变量,但总是增加+1?(因为索引= 0页显然是第1页,因此应显示为Page 1)
<input type="text" ng-model="page.pageNumber">
Run Code Online (Sandbox Code Playgroud)
此外,当模型更新时,输入中的值应自动更改(再次:也增加+1).
当在期间找到重复的键条目时Collectors.toMap(),(o1, o2)调用合并功能.
问题:如何获取导致重复的密钥?
String keyvalp = "test=one\ntest2=two\ntest2=three";
Pattern.compile("\n")
.splitAsStream(keyval)
.map(entry -> entry.split("="))
.collect(Collectors.toMap(
split -> split[0],
split -> split[1],
(o1, o2) -> {
//TODO how to access the key that caused the duplicate? o1 and o2 are the values only
//split[0]; //which is the key, cannot be accessed here
},
HashMap::new));
Run Code Online (Sandbox Code Playgroud)
在合并函数内部,我想根据键来决定,如果我取消映射,或继续并接受这些值.
如果我创建一个具有application.properties定义通用配置的公共库.喜欢:
spring.main.banner-mode=off
如何将这些属性继承到另一个包含那些公共库的项目中?
Maven的:
<project ...>
<groupId>de.mydomain</groupId>
<artifactId>my-core</artifactId>
<version>1.0.0</version>
<dependencies>
<dependency>
<!-- this one holds the common application.properties -->
<groupId>my.domain</groupId>
<artifactId>my-commons</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)
我怎样才能继承从配置my-commons到 my-core?
java ×9
spring ×3
angularjs ×1
annotations ×1
collections ×1
collectors ×1
hibernate ×1
java-8 ×1
java-ee ×1
javadoc ×1
javascript ×1
log4j2 ×1
logging ×1
regex ×1
spring-boot ×1
sql ×1