我已经声明了这样的注释:
public @interface CustomAnnot
{
String[] author() default "me";
String description() default "";
}
Run Code Online (Sandbox Code Playgroud)
因此有效的注释将是
@CustomAnnot(author="author1", description="test")
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚的是,如何设置多个作者,因为author()返回String []这应该是可能的.
@CustomAnnot(author="author1","autor2", description="test")
Run Code Online (Sandbox Code Playgroud)
不起作用!
我刚刚将JDK更新为JDK 1.8,因为我无法在1.7版本中找到java FX所需的jfxrt.jar.
我从这里下载了JDK:http: //www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
特别是版本:jdk-8u5-linux-i586.rpm
顺便说一下,我使用opensuse 13.1.
现在安装完成后,我的usr/java/jdk1.9_05/lib仍然不包含jfxrt.jar.
有没有人知道为什么,我读到这个版本实际上应该包含它.我可以解决这个问题吗?
我有这样的课
public class Example {
private List<Integer> ids;
public getIds() {
return this.ids;
}
}
Run Code Online (Sandbox Code Playgroud)
如果我有这样的类的对象列表
List<Example> examples;
Run Code Online (Sandbox Code Playgroud)
我怎样才能将所有示例的id列表映射到一个列表中?我试过这样的:
List<Integer> concat = examples.stream().map(Example::getIds).collect(Collectors.toList());
Run Code Online (Sandbox Code Playgroud)
但得到一个错误 Collectors.toList()
使用Java 8 stream api获得此功能的正确方法是什么?
对于我的学习,我必须编写以下函数,该函数在两个国家之间获得最短路径.我已经编写了一个函数isRoute,它检查两个国家之间是否存在连接,以及函数yieldRoute,它只返回两个国家之间的连接.现在我必须编写一个函数,它返回两个国家之间的最短路径.
我的第一个方法是获得两国之间的所有联系,然后获得最短的连接,但在我看来,获得所有连接对于programm来说有点烦人.现在我想出了实现dijstra算法的想法,但实际上我觉得这也很难.你们能告诉我怎么做这个吗?
我们必须使用这些类型(我们不允许更改它们,但我们可以添加新类型.)
type Country = String
type Countries = [Country]
type TravelTime = Integer -- Travel time in minutes
data Connection = Air Country Country TravelTime
| Sea Country Country TravelTime
| Rail Country Country TravelTime
| Road Country Country TravelTime deriving (Eq,Ord,Show)
type Connections = [Connection]
data Itinerary = NoRoute | Route (Connections,TravelTime) deriving (Eq,Ord,Show)
Run Code Online (Sandbox Code Playgroud)
我的收益路线功能只是广泛的第一次搜索:( Sry for german comments)
-- Liefert eine Route falls es eine gibt
yieldRoute :: Connections -> Country -> Country -> Connections
yieldRoute …Run Code Online (Sandbox Code Playgroud) 我试图写入node.js中的文本文件.我这样做的方式如下:
fs.writeFile("persistence\\announce.txt", string, function (err) {
if (err) {
return console.log("Error writing file: " + err);
}
});
Run Code Online (Sandbox Code Playgroud)
而string是一个变量.
此函数将始终在文件的开头写入,因此它将覆盖以前的内容.
我在以下情况下遇到问题:
旧内容:
Hello Stackoverflow
Run Code Online (Sandbox Code Playgroud)
新写:
Hi Stackoverflow
Run Code Online (Sandbox Code Playgroud)
现在,以下内容将在文件中:
Hi stackoverflowlow
Run Code Online (Sandbox Code Playgroud)
新写入比之前的内容短,因此旧内容的一部分仍然是持久的.
我的问题:
我需要做什么,以便在新写入之前完全删除文件的旧内容?
body {
background: url(http://leona-anderson.com/wp-content/uploads/2014/10/finalbackgroundMain.png) fixed;
background-size:100% auto;
}
Run Code Online (Sandbox Code Playgroud)
我在每个站点上都有不同的背景图像,因为它们是1080p,它们需要加载一些.
我使用带有minamaze主题的wordpress 4.0.5.
我发现我使用了预加载的javascript函数,但在我的情况下在首页我没有关于其他网站的背景图像的信息所以我希望有人可以为我提供不同的解决方案.
我的图像是大约1mb大小的.pngs,也许我还可以尝试再压缩一些?
提前致谢
为了在我的Kotlin项目中进行日志记录,我使用的是kotlin-logging,这非常好用但是我错过了一个非常重要的问题:如何配置记录器的日志级别?
默认情况下,它设置为info,我想将其设置为调试.由于Github页面上没有任何内容,也没有任何方法可以通过编程方式设置级别,所以我查看了slf4j,因为kotlin-logging是一个包装器.
显然我必须像这样设置一个系统属性:
-Dorg.slf4j.simpleLogger.defaultLogLevel=DEBUG
Run Code Online (Sandbox Code Playgroud)
但是我不知道怎么在Kotlin这样做.
有人可以帮帮我吗?
我正在使用Kotlin并尝试在特定方法调用上引发Exception,但始终会收到以下错误
Checked exception is invalid for this method!
Invalid: exceptions.ServiceException
Run Code Online (Sandbox Code Playgroud)
这是测试
val client : IClient = Mockito.spy(Client(Cnf("https://:region.example.com", key)))
@Test(expected = ServiceException::class)
fun test400ResponseFrom() {
val url = "https://example.com/example/user/v3/user/by-name/JACKAPPLE"
Mockito.doThrow(ServiceException("Bad Request")).`when`(client).makeRequest(url ,riotkey)
client.getUserDataByNameAndRegion("jackapple", "BR")
}
Run Code Online (Sandbox Code Playgroud)
基本上,该getUserDataByNameAndRegion方法将调用该makeRequest方法,并且通过此测试,我想验证该方法是否正确处理了存根方法的结果。
原始方法如下所示
@Throws(NotFoundException::class, ServiceException::class)
fun makeRequest(url: String, key : String) : String {
val con = prepareConnection(url, key)
val statusCode = con.responseCode
when {
(statusCode == 400) -> throw ServiceException("Bad Request")
(statusCode == 401) -> throw ServiceException("Unauthorized")
(statusCode == 403) -> throw …Run Code Online (Sandbox Code Playgroud) 我遇到了 JPA 问题,无法解决。
我在 glassfish 3+ 上部署我的 web 应用程序,当应该构建 EntityManagerFactory 时,它总是抛出异常:
javax.persistence.PersistenceException: [PersistenceUnit: lab4] Unable to build EntityManagerFactory
Run Code Online (Sandbox Code Playgroud)
这是堆栈跟踪:
javax.faces.el.EvaluationException: javax.persistence.PersistenceException: [PersistenceUnit: lab4] Unable to build EntityManagerFactory
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1542)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at …Run Code Online (Sandbox Code Playgroud) 好的,我刚刚完成了大学的任务,并希望在他们的服务器上测试我的解决方案并获得此异常:
[java] Exception in thread "main" java.lang.UnsupportedClassVersionError: controller/CloudController : Unsupported major.minor version 52.0
[java] at java.lang.ClassLoader.defineClass1(Native Method)
[java] at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
[java] at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
[java] at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
[java] at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
[java] at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
[java] at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
[java] at java.security.AccessController.doPrivileged(Native Method)
[java] at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
[java] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
[java] at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
[java] Java Result: 1
Run Code Online (Sandbox Code Playgroud)
I checked the server and found out they are using Java 7 while I used Java 8 already.
What I then tried …