如何让Java 8与Eclipse一起工作?
我已按照本指南但不起作用.我也看过Eclipse Java 8 wiki页面,但他们没有解释如何处理签出的git存储库.
我们为什么要在Java中声明一个类中的接口?
例如:
public class GenericModelLinker implements IModelLinker {
private static final Logger LOG =LoggerFactory.getLogger(GenericModelLinker.class);
private String joinAsPropertyField;
private boolean joinAsListEntry;
private boolean clearList;
private List<Link> joins;
//instead of a scalar property
private String uniqueProperty;
public interface Link {
Object getProperty(IAdaptable n);
void setProperty(IAdaptable n, Object value);
}
}
Run Code Online (Sandbox Code Playgroud) 下面是我希望渲染具有透明背景的圆角容器的代码.
return new Container(
//padding: const EdgeInsets.all(32.0),
height: 800.0,
//color: const Color(0xffDC1C17),
//color: const Color(0xffFFAB91),
decoration: new BoxDecoration(
color: Colors.green, //new Color.fromRGBO(255, 0, 0, 0.0),
borderRadius: new BorderRadius.only(
topLeft: const Radius.circular(40.0),
topRight: const Radius.circular(40.0))
),
child: new Container(
decoration: new BoxDecoration(
color: Colors.blue,
borderRadius: new BorderRadius.only(
topLeft: const Radius.circular(40.0),
topRight: const Radius.circular(40.0))
),
child: new Center(
child: new Text("Hi modal sheet"),
)
),
Run Code Online (Sandbox Code Playgroud)
然而,这是它呈现的内容,它呈现一个圆角半径的白色容器(预期透明).有帮助吗?
有没有办法获得给定项目集的Maven依赖图(如果可能的话,图形化),而没有绘制第三方依赖项?或者我选择退出我不感兴趣的依赖项?
我想将工具/插件指向许多POM文件,并查看这些项目之间的依赖关系的描述.
我使用maven-enforcer-plugin来检查依赖性收敛问题.典型的输出是:
[WARNING] Rule 1: org.apache.maven.plugins.enforcer.DependencyConvergence failed
with message:
Failed while enforcing releasability the error(s) are [
Dependency convergence error for junit:junit:3.8.1 paths to dependency are:
+-foo:bar:1.0-SNAPSHOT
+-ca.juliusdavies:not-yet-commons-ssl:0.3.9
+-commons-httpclient:commons-httpclient:3.0
+-junit:junit:3.8.1
and
+-foo:bar:1.0-SNAPSHOT
+-junit:junit:4.11
]
Run Code Online (Sandbox Code Playgroud)
看到这条消息,我通常会通过排除传递依赖来"解决"它,例如
<dependency>
<groupId>ca.juliusdavies</groupId>
<artifactId>not-yet-commons-ssl</artifactId>
<version>0.3.9</version>
<exclusions>
<!-- This artifact links to another artifact which stupidly includes
junit in compile scope -->
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我想了解这是否真的是一个解决方案以及以这种方式排除库的风险.照我看来:
如果我选择使用较新版本,"修复"通常是安全的.这依赖于库作者保持向后兼容性.
通常对Maven构建没有影响(因为更接近的定义获胜),但是通过排除依赖性我告诉Maven我知道这个问题并因此安抚maven-enforcer-plugin.
我的想法是否正确,是否有另一种处理此问题的方法?我对那些关注一般情况的答案感兴趣 - 我意识到junit
上面的例子有点奇怪.
我无法弄清楚为什么doNothing
不能为此工作?有任何想法吗?
@Captor
ArgumentCaptor<GenericClass<someOtherClass>> captor;
...
Mockito.doNothing().when(mockObject.methodToStub(captor.capture()));
Run Code Online (Sandbox Code Playgroud)
错误是:
Exception: when(java.lang.Void) in Stubber cannot be applied to void
我在maven POM.xml中有以下XML:
<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
<property>
<name>default</name>
<value>!disabled</value>
</property>
</activation>
<modules>
<module>m1</module>
<module>m2</module>
<module>m3</module>
</modules>
</profile>
<profile>
<id>x</id>
<modules>
<module>m1</module>
</modules>
</profile>
</profiles>
Run Code Online (Sandbox Code Playgroud)
我想要实现的是:
当我跑步时mvn install
,我希望它能够建立m1,m2和m3项目.
当我跑步时mvn install -Px
,我希望它只能构建m1.
我目前的问题是,使用上面的代码,选项2构建所有m1,m2和m3.
如果你执行:
System.out.println(someObj.toString());
Run Code Online (Sandbox Code Playgroud)
你可能看到输出像
someObjectClassname @ hashcodenumber
我的问题:有什么特定的原因可以显示hashCode编号吗?
我已将项目从使用GCM迁移到使用Firebase.当设备处于唤醒状态或最近处于睡眠状态时,推送通知会通过确认,但如果我离开设备一小时,则在我唤醒设备之前不会发送推送.
Android文档说,如果您需要唤醒设备以传递消息,请使用优先级设置为高的FireBase.它还说设备管理应用程序不受Doze限制,我的应用程序是一个设备管理应用程序.
我想我会提到当我将项目从GCM迁移到FCM时,我只在firebase控制台中指定了包名,而不是指纹.
我试过了什么
将优先级设置为高
{
"time_to_live": 300000,
"delay_while_idle": false,
"android": {
"priority": "high"
},
"data": {
"message": "PING_DEVICE",
"time": "21/01/2018 16:20:28",
"pushguid": "10062"
},
"registration_ids": [
"eOMT........"
]
}
Run Code Online (Sandbox Code Playgroud)
设定生存时间,以便最终传达信息.delay_while_idle设置为false,2016年9月后FCM将忽略此值.
设备管理员应用程序不受Doze的影响,我的设备管理员应用程序,但我还明确将应用程序添加到设置 - >电池 - >优化中的Doze白名单中.这是通过设置应用程序手动完成的,而不是以编程方式在代码中完成
我已经离开我的设备睡了3个小时,没有推动通过.我还使用adb将设备置于Doze中.当adb将设备置于Doze中时,没有收到推送,当adb将设备从Doze中取出时,推送就会通过.
进一步的想法我没试过.
我的推动是数据消息.这是因为我不希望推送到设备上的通知栏并让用户单击它来执行功能.用户没有与设备管理应用程序的交互.因此,数据消息由处理
onMessageReceived(RemoteMessage remoteMessage)
Run Code Online (Sandbox Code Playgroud)
我相信通知消息会唤醒设备,这是我需要的,但我希望应用程序处理推送,而不是用户.我可以拥有通知和数据但是onMessageRecievied处理功能的消息吗?
有没有人经历过类似的事情或有任何解决方案?
[编辑1]我在下面找到了以下链接,说明您可以发送通知和数据的消息,但如果应用程序在后台,则会显示通知,但只有在用户单击通知时才会执行数据.这不是我想要的,因为我希望数据立即在onMessageRecived中执行.
[EDIT2]我已向应用添加了以下代码和权限.该应用程序现在要求用户将应用程序列入白名单,因此我单击是.然后我通过adb将设备放入Doze并发送推送.在我将设备退出打盹模式之前,没有任何事情发生.所以,不幸的是,这不起作用.
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Intent intent = new Intent();
String packageName = getPackageName();
PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
if (!pm.isIgnoringBatteryOptimizations(packageName)) {
intent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
intent.setData(Uri.parse("package:" + packageName));
startActivity(intent);
}
}
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
Run Code Online (Sandbox Code Playgroud)
[EDIT3]
我已经做了进一步的测试,试图找出问题并将我的Web应用程序代码排除在外.我通过adb和使用过的FireBase控制台将设备置于Doze中以发送推送.推送正确 …
我有一个函数返回映射值(String)作为通用对象.如何将其转换回字符串.我试过toString(),但我得到的只是end[Ljava.lang.String;@ff2413
public Object getParameterValue(String key)
{
Iterator iterator=params.entrySet().iterator();
while(iterator.hasNext())
{
Map.Entry me=(Map.Entry)iterator.next();
String[] arr=(String[])me.getValue();
log.info(me.getKey().toString()+"="+arr[0]);
}
if(params.containsKey(key))
{
log.info(key+"="+params.get(key));
return params.get(key);
}
return null;
}
Run Code Online (Sandbox Code Playgroud)
接收结束
String temp=data.getParameterValue("request").toString();
log.info("end"+temp);
Run Code Online (Sandbox Code Playgroud)
log.info(me.getKey().toString()+"="+arr[0]);
给我一个输出
email=x@as.com request=login projectid=as