到目前为止,我已经能够找到如何在文件的开头添加一行,但这不是我想要的.我将在一个例子中展示它
文件内容
some text at the beginning
Run Code Online (Sandbox Code Playgroud)
结果
<added text> some text at the beginning
Run Code Online (Sandbox Code Playgroud)
它是类似的,但我不想用它创建任何新的线...
sed如果可能的话,我想这样做.
突然间,这在JUnit测试期间不断发生.一切正常,我写了一些新的测试,发生了这个错误.如果我还原它,它就不会消失.这是为什么?
log4j:WARN No appenders could be found for logger (org.springframework.test.context.junit4.SpringJUnit4ClassRunner).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Run Code Online (Sandbox Code Playgroud) 我在Macos 10.5和Java 1.5.0.19上使用eclipse 3.5(cocoa build).
我只有3个java文件打开1个文件~2000行另外2个是~700行.
但是当我从1个文件选项卡切换到另一个时,eclipse需要很长时间(约20秒)才能切换到另一个选项卡.
我已经将eclipse.ini更改为
more eclipse.ini
-startup
../../../plugins/org.eclipse.equinox.launcher_1.0.200.v20090520.jar
--launcher.library
../../../plugins/org.eclipse.equinox.launcher.cocoa.macosx_1.0.0.v20090519
-product
org.eclipse.epp.package.jee.product
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
-vmargs
-Dosgi.requiredJavaVersion=1.5
-XstartOnFirstThread
-Dorg.eclipse.swt.internal.carbon.smallFonts
-XX:MaxPermSize=512m
-Xms128m
-Xmx1024m
-Xdock:icon=../Resources/Eclipse.icns
-XstartOnFirstThread
-Dorg.eclipse.swt.internal.carbon.smallFonts
Run Code Online (Sandbox Code Playgroud)
有没有办法让eclipse 3.5更快速?
谢谢.
我有这个代码:
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
logger.info("Filter start...");
HttpServletRequest httpRequest = (HttpServletRequest) request;
HttpServletResponse httpResponse = (HttpServletResponse) response;
String ba = getBaId(getBody(httpRequest));
if (ba == null) {
logger.error("Wrong XML");
httpResponse.setStatus(HttpServletResponse.SC_BAD_REQUEST);
} else {
if (!clients.containsKey(ba)) {
clients.put(ba, 1);
logger.info("Client map : init...");
} else {
clients.put(ba, clients.get(ba).intValue() + 1);
logger.info("Threads for " + ba + " = " + clients.get(ba).toString());
}
chain.doFilter(request, response);
}
}
Run Code Online (Sandbox Code Playgroud)
和这个web.xml(包缩短和名称更改,但它看起来相同)
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app>
<filter>
<filter-name>TestFilter</filter-name> …Run Code Online (Sandbox Code Playgroud) 我的Spring基于注释的任务调度程序有问题 - 我无法使其工作,我在这里看不到任何问题...
应用程序的context.xml
<task:scheduler id="taskScheduler" />
<task:executor id="taskExecutor" pool-size="1" />
<task:annotation-driven executor="taskExecutor" scheduler="taskScheduler" />
Run Code Online (Sandbox Code Playgroud)
豆
@Service
public final class SchedulingTest {
private static final Logger logger = Logger.getLogger(SchedulingTest.class);
@Scheduled(fixedRate = 1000)
public void test() {
logger.debug(">>> Scheduled test service <<<");
}
}
Run Code Online (Sandbox Code Playgroud) 是否有可能做出这样的事情?我知道implements不能在<>中,但我想以某种方式将T限制为Serializable.
public class Clazz<T implements Serializable> {
...
}
Run Code Online (Sandbox Code Playgroud) 我知道这已被多次询问,但我从上到下阅读了文档,在这里阅读了所有答案,但没有一个帮助.说实话,每个答案都说明了如何解决这个问题.
现在回到我的问题.我想从某些活动更新小部件列表视图,我WidgetProvider#sendUpdateBroadcastToAllWidgets()为此目的创建了我从活动中调用的内容.
它最终调用,onUpdate()以便正确接收广播.但意见没有刷新.
我也尝试调用AppWidgetManager#notifyAppWidgetViewDataChanged()和刷新数据,WidgetFactory#onDataSetChanged()但从未调用过该方法.
所以我猜这一切都行不通,因为远程视图工厂被缓存但我不知道如何可靠地克服这一点.有什么想法吗?
那些背景呢?我总是要提供一个,但我真的不在乎哪一个.有关系吗?
谢谢
提供商
public class WidgetProvider extends AppWidgetProvider {
public static void sendUpdateBroadcastToAllWidgets(Context context) {
int allWidgetIds[] = AppWidgetManager.getInstance(context).getAppWidgetIds(new ComponentName(context, WidgetProvider.class));
Intent intent = new Intent(context, WidgetProvider.class);
intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, allWidgetIds);
context.sendBroadcast(intent);
}
@Override
public void onUpdate(Context context, AppWidgetManager widgetManager, int[] widgetIds) {
for (int id : widgetIds) {
updateWidget(context, widgetManager, id);
}
super.onUpdate(context, widgetManager, widgetIds);
}
@Override
public void onDeleted(Context context, int[] widgetIds) {
WidgetPreferences prefs = …Run Code Online (Sandbox Code Playgroud) 到目前为止,我有两个测试.一个只使用jUnit框架并且工作正常.另一个使用spring-test库并在每次尝试运行时创建此异常.什么可能导致问题的想法?
错误
java.lang.NoSuchFieldError: NULL
at org.junit.runners.ParentRunner.<init>(ParentRunner.java:48)
at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:59)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.<init>(SpringJUnit4ClassRunner.java:104)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:27)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:32)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:41)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:31)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Run Code Online (Sandbox Code Playgroud)
Maven测试依赖项
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${org.springframework.version}</version>
<scope>test</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
依赖树
[INFO] [dependency:tree {execution: default-cli}]
[INFO] fake:war:1.0-SNAPSHOT
[INFO] +- log4j:log4j:jar:1.2.16:compile
[INFO] +- org.springframework:spring-web:jar:3.0.5.RELEASE:compile
[INFO] | +- aopalliance:aopalliance:jar:1.0:compile
[INFO] | +- org.springframework:spring-beans:jar:3.0.5.RELEASE:compile
[INFO] | +- org.springframework:spring-context:jar:3.0.5.RELEASE:compile
[INFO] | | +- org.springframework:spring-aop:jar:3.0.5.RELEASE:compile …Run Code Online (Sandbox Code Playgroud) 我正在使用Apache CXF从WSDL文件生成类,但它们不实现将对象放入JMS队列所需的Serializable.是可以这样做还是我必须将生成的类转换为我自己的类并发送它们?
我在一个论坛上有一个主题,人们可以写出他们的十大歌曲列表.我想计算一首歌被列出的次数.必须比较相似性不区分大小写.
文件结构示例:
Join Date: Apr 2005
Location: bama via new orleans
Age: 48
Posts: 2,369
Re: Top 10 Songs Jethro Tull
oh dearrrr. the only way for all kaths to keep their last shred of sanity: fly through this list as quickly as possible, without stopping to think for a microsecond...
velvet green
dun ringill
skating away on the thin ice of a new day
sossity yer a woman
fat man
life's a long song
jack-a-lynn
teacher
mother goose
elegy …Run Code Online (Sandbox Code Playgroud)