我想要一个这样的页面:
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:m="mine.xsd">
<m:dialog m:title="Hello">Hi there!</m:dialog>
</html>
Run Code Online (Sandbox Code Playgroud)
我怎么写"mine.xsd"?
我想为整个包设置一个配置文件名称,但我不知道如何做。如果哪里没有简单的方法,那么我必须用@Profile注释标记包和子包中的每个类。
<context:component-scan/>标签不支持这样的属性profile,所以我不知道。
public interface Filter<M> {
boolean match(M m);
public static <T> Collection<T> filter(Collection<T> collection, Filter<T> filter) {
return collection.stream().filter(filter::match).collect(Collectors.toList());
}
////////////////////////////////////////////////////////////////
public static void main(String[] args) {
ArrayList<Integer> intList = new ArrayList<>(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8));
System.out.println(intList);
List<Integer> list = filter(intList, null);
System.out.println(list);
}
}
Run Code Online (Sandbox Code Playgroud)

我正在学习java 8流媒体功能,这是我有问题的代码......
我不知道为什么参数intList不符合filter()方法.Java应该知道<T>在Integer这里,对吗?
我的Android应用程序正在使用支持v4库:
<uses-sdk
android:minSdkVersion="7"
android:maxSdkVersion="19"
android:targetSdkVersion="19" />
Run Code Online (Sandbox Code Playgroud)
它只是作为一个新项目创建的.当我在手机上运行并按下菜单按钮时,它会崩溃:
12-21 15:12:54.170 31705-31705/com.talkweb.woplus E/AndroidRuntime:FATAL EXCEPTION:android.support.v7.app.ActionBarImplICS.getThemedContext(ActionBarImplICS.java:287)中的主要java.lang.NullPointerException Android.support.v7.app.ActionBarActivity.getMenuInflater中android.support.v7.app.ActionBarActivityDelegate.getMenuInflater(ActionBarActivityDelegate.java:98)的android.support.v7.app.ActionBarImplJB.getThemedContext(ActionBarImplJB.java:20) ActionBarActivity.java:71)在android.app.Activity.onCreatePanelMenu(Activity.java:2652)的com.talkweb.woplus.HomeActivity.onCreateOptionsMenu(HomeActivity.java:35)
HomeActivity.java中的代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE); // I add this line
setContentView(R.layout.activity_home);
if (savedInstanceState == null) {
webViewFragment = new WebViewFragment();
getSupportFragmentManager().beginTransaction()
.add(R.id.container, webViewFragment)
.commit();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.home, menu); // line: 35
return true;
}
Run Code Online (Sandbox Code Playgroud)
styles.xml:
<resources>
<!-- Base application theme. --> …Run Code Online (Sandbox Code Playgroud) 我有一个启动线程并运行一些后台任务的服务类。在运行单元测试时,不应运行这些任务。服务类本身非常简单,因此不需要进行单元测试。它就像是:
@Service
public class BackgroundTaskService {
@PostConstruct
public void startTask() {
// ...
}
}
Run Code Online (Sandbox Code Playgroud)
当前,我正在设置系统属性以声明正在运行单元测试:
@RunWith(SpringRunner.class)
@SpringBootTest
public class SomeTest {
static {
System.setProperty("unit_testing", "true");
}
@Test
public void test() {}
}
Run Code Online (Sandbox Code Playgroud)
然后,我可以检查:
@PostConstruct
public void startTask() {
if (System.getProperty("unit_testing") != null) {
return; // skip background tasks
}
}
Run Code Online (Sandbox Code Playgroud)
我想知道是否有更好的方法可以做到这一点。