我正在研究弹簧可能切换到弹簧组.我认为很酷的一件事是spring jdbc能够记录所有已执行的sql.所以我放入了log4j,设置了一个log4j.properties文件.而且没有sql.
这是log4j.properties文件:
log4j.appender.stdout=org.apache.log4j.ConsoleAppe nder
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.Patt ernLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ ABSOLUTE} %5p %c{1}:%L - %m%n
log4j.rootLogger=debug, stdout
log4j.category.org.springframework.jdbc.core=DEBUG
Run Code Online (Sandbox Code Playgroud)
这里是一些非常简单的插入sql的输出,通过spring jdbc:http://pastie.org/713189
我有一个通过项目向导设置的导航控制器.当前启动应用程序时,将自动创建并显示导航控制器.
我现在需要通过代码而不是通过.xib魔法来控制导航控制器的显示.如何禁用MainWindow.xib/RootViewController.xib的自动创建?我承认我实际上并不知道发生了什么以及MainWindow.xib和RootController.xib之间的关系,因为向导设置了所有这些.
这方面的任何参考或代码片段都会有所帮助..谢谢!
我正在尝试编写一个单元测试,它将针对XSD验证XML字符串文档.请注意,XSD存储在磁盘上,用于XML文档中名称空间的URL实际上不能通过Web服务器获得.
这是代码:
@Test
public void testValidateAgainstXSD() throws Exception {
String xmlDoc = MY_XML_DOC_SAMPLE;
File schemaFile = new File("/Users/philswenson/dev/optimize_l/modules/ae/staging/eda-eventtypes/Analysis/1.0/MeasurementResultStatistics.xsd");
Source xmlFile = new StreamSource(xmlDoc);
SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = schemaFactory.newSchema(schemaFile);
Validator validator = schema.newValidator();
try {
validator.validate(xmlFile);
System.out.println(xmlFile.getSystemId() + " is valid");
} catch (SAXException e) {
throw new RuntimeException(e);
}
}
Run Code Online (Sandbox Code Playgroud)
当我运行测试时,我得到以下错误.关于我做错了什么的任何想法?
java.net.MalformedURLException: no protocol: <?xml version="1.0" encoding="utf-8"?>
<p:MeasurementResultStatistics xmlns:p="http://namespaces.myco.com/EDA/Analysis/1.0"> <p:Average>5.0</p:Average>
<p:Minimum>0.1</p:Minimum>
<p:Maximum>10.3</p:Maximum>
<p:StandardDeviation>0.0</p:StandardDeviation>
<p:HourOfDay>7</p:HourOfDay>
<p:DayOfWeek>Mon</p:DayOfWeek>
<p2:MeasurementDefinition xmlns:p2="http://namespaces.myco.com/EDA/Analysis/1.0">
<p2:Name>TEST KPI NAME</p2:Name>
<p2:DisplayName>TEST DISPLAY NAME</p2:DisplayName>
<p2:Version>1</p2:Version>
<p2:MeasurementUnits>TEST UOM</p2:MeasurementUnits>
<p2:TimeInterval>10000</p2:TimeInterval> …Run Code Online (Sandbox Code Playgroud) this works:
ids = [1,2]
varietals = Varietal.find(:all, :conditions => [ "id IN (?)",ids])
Run Code Online (Sandbox Code Playgroud)
But what I want to do is that plus have a condition of: deleted => false
varietals = Varietal.find(:all, :conditions =>{ :deleted => false})
Run Code Online (Sandbox Code Playgroud)
any ideas?
am i going to have to use find_by_sql?
我正在设置一个新的jenkins服务器并遇到问题.在同步我的svn repo时,我在外部会出现此错误:
Caused by: org.tmatesoft.svn.core.SVNCancelException: svn: E200015: No
credential to try. Authentication failed
at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.cancel(SVNErrorManager.java:37)
at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.cancel(SVNErrorManager.java:32)
at org.tmatesoft.svn.core.internal.wc.DefaultSVNAuthenticationManager.getFirstAuthentication(DefaultSVNAuthenticationManager.java:185)
at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection._request(HTTPConnection.java:598)
at org.tmatesoft.svn.core.internal.io.dav.http.HTTPConnection.request(HTTPConnection.java:298)
... 40 more
Caused by: svn: E200015: No credential to try. Authentication failed
at org.tmatesoft.svn.core.SVNErrorMessage.create(SVNErrorMessage.java:208)
at org.tmatesoft.svn.core.SVNErrorMessage.create(SVNErrorMessage.java:154)
at org.tmatesoft.svn.core.SVNErrorMessage.create(SVNErrorMessage.java:97)
... 45 more
Run Code Online (Sandbox Code Playgroud)
用于主仓库的凭证应该可以在任何地方使用(它们在其他Jenkins实例上执行).
有任何想法吗?
更新凭证的正确程序是什么?
谢谢
我觉得是时候为我的iPhone应用程序编写一些测试了.不幸的是,这并不顺利.我创建了一个新的测试类但是得到了下面的错误.看起来它正在向我提供OS X库但我不知道为什么......
Ld /Users/philswenson/Library/Developer/Xcode/DerivedData/3rdRevolution-crkklmdwurdjtrbjvjedcqqeoyvk/Build/Products/Debug-iphonesimulator/3rdRevolutionTests.octest/3rdRevolutionTests normal i386
cd /Users/philswenson/dev/3rdRev/3R_iOS
setenv IPHONEOS_DEPLOYMENT_TARGET 7.0
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 -bundle -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk -L/Users/philswenson/Library/Developer/Xcode/DerivedData/3rdRevolution-crkklmdwurdjtrbjvjedcqqeoyvk/Build/Products/Debug-iphonesimulator -F/Users/philswenson/Library/Developer/Xcode/DerivedData/3rdRevolution-crkklmdwurdjtrbjvjedcqqeoyvk/Build/Products/Debug-iphonesimulator -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/Developer/Library/Frameworks -F/Applications/Xcode.app/Contents/Developer/Library/Frameworks -filelist /Users/philswenson/Library/Developer/Xcode/DerivedData/3rdRevolution-crkklmdwurdjtrbjvjedcqqeoyvk/Build/Intermediates/3rdRevolution.build/Debug-iphonesimulator/3rdRevolutionTests.build/Objects-normal/i386/3rdRevolutionTests.LinkFileList -bundle_loader /Users/philswenson/Library/Developer/Xcode/DerivedData/3rdRevolution-crkklmdwurdjtrbjvjedcqqeoyvk/Build/Products/Debug-iphonesimulator/3rdRevolution.app/3rdRevolution -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=7.0 -framework SenTestingKit -framework UIKit -framework Foundation -Xlinker -dependency_info -Xlinker /Users/philswenson/Library/Developer/Xcode/DerivedData/3rdRevolution-crkklmdwurdjtrbjvjedcqqeoyvk/Build/Intermediates/3rdRevolution.build/Debug-iphonesimulator/3rdRevolutionTests.build/Objects-normal/i386/3rdRevolutionTests_dependency_info.dat -o /Users/philswenson/Library/Developer/Xcode/DerivedData/3rdRevolution-crkklmdwurdjtrbjvjedcqqeoyvk/Build/Products/Debug-iphonesimulator/3rdRevolutionTests.octest/3rdRevolutionTests
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_XCTestCase", referenced from:
_OBJC_CLASS_$_IsoDateTest in IsoDateTest.o
"_OBJC_METACLASS_$_XCTestCase", referenced from:
_OBJC_METACLASS_$_IsoDateTest in IsoDateTest.o
"__XCTFailureFormat", referenced from:
-[IsoDateTest testExample] in IsoDateTest.o
"__XCTFailureHandler", referenced from:
-[IsoDateTest testExample] in IsoDateTest.o …Run Code Online (Sandbox Code Playgroud) 我需要一个命令来返回 bash 中指定路径的顶级基本目录。
我有一个可行的方法,但看起来很丑:
echo "/go/src/github.myco.com/viper-ace/psn-router" | cut -d "/" -f 2 | xargs printf "/%s"
Run Code Online (Sandbox Code Playgroud)
似乎有更好的方法,但是我见过的所有替代方法似乎都更糟糕。
感谢您的任何建议!
errorString="AxisFault\n
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException\n
faultSubcode: \n
faultString: My Error\n
faultActor: \n
faultNode: \n
faultDetail: \n
{}string: this is the fault detail"
Pattern pattern = Pattern.compile(".*faultString(.*)", Pattern.DOTALL);
Matcher matcher = pattern.matcher(errorString);
if (matcher.matches()) {
String match = matcher.group(1);
return match;
}
Run Code Online (Sandbox Code Playgroud)
我想得到"我的错误",但它返回到整个字符串的末尾,而不是匹配到faultString行末尾的\n.我已经尝试了许多技术让它在线路末端停止,但没有成功.
谢谢
我想我最后应该为我的rails应用程序编写一些测试.
我的控制器是"UsersController".它没有任何HTML,因为我只有一个iphone应用程序发送一个帖子到rails控制器.
这是我的测试:
require 'test_helper'
class UsersControllerTest < ActionController::TestCase
def test_create
# to http post
# /users
#user[email]=%@&user[password]=%@&user[password_confirmation]=%@
#post
post(:create, :user => {:password => "testpassword", :password_confirmation => "testpassword"})
end
Run Code Online (Sandbox Code Playgroud)
问题是我收到此错误:
1)错误:test_create(的UsersControllerTest):::的ActionView MissingTemplate:缺少模板用户/新含{:处理器=> [:ERB,:RJS,:助洗剂,:RHTML,:RXML]:格式=> [:HTML] ,:locale => [:en,:en]}在视图路径中
所以我猜它正在尝试填充HTML页面?如果是这样,我发现这很奇怪.我认为它会直接向控制器发帖.有人可以确认这个"post"方法尝试并填充HTML表单吗?
如果是这种情况,我应该如何编写测试以直接向控制器发送HTTP帖子?
谢谢你的帮助
我正在尝试从运行时添加的 Jar 文件加载资源,但没有走得太远。
这是我的代码(常规):
URL url = new URL("jar:file:/out/resource.jar!/test.resource")
def urlList = [] << url
URL[] urls = urlList.toArray()
URLClassLoader classLoader = new URLClassLoader(urls, this.class.getClassLoader())
InputStream stream = url.openStream()
Run Code Online (Sandbox Code Playgroud)
我收到此错误: java.util.zip.ZipException: error in opening zip file at java.util.zip.ZipFile.open(Native Method)
问题:
1)我需要在我的网址中添加“test.resource”吗?2)我的URLClassLoader和我当前类的类加载器之间有什么关系?3)流式传输此资源的正确方法是什么(显然我所拥有的不起作用)?
谢谢
我的iOS应用程序遇到了问题.这是我对相关组件的票证:https://github.com/lxcid/LXReorderableCollectionViewFlowLayout/issues/52
但对于StackOverflow - 我的问题更为笼统.怎么去调试这样的东西?
我得到的唯一错误是:
2013-12-16 18:23:24.307 3rdRevolution[33315:70b] *** -[CFSet countByEnumeratingWithState:objects:count:]: message sent to deallocated instance 0x1336f850
(lldb)
Run Code Online (Sandbox Code Playgroud)
这是xcode的截图:

我确实发现LXReordableCollectionView通过注释掉它的用法来解决崩溃问题.但我仍然不知道为什么或如何解决它.并注释掉代码来解决问题似乎并不是一个好方法..
建议?
谢谢!
我需要设置一个仅在登录用户是admin(user.admin?)时使用devise才有效的路由.我正在为sidekiq做这个,但问题对任何类似的用途都有效.
这是我的路线代码:
class AdminConstraint
def matches?(request)
!request.session['warden.user.user.key'].nil? and request.session['warden'].user.admin?
end
end
require 'sidekiq/web'
mount Sidekiq::Web => '/sidekiq', :constraints => AdminConstraint.new
Run Code Online (Sandbox Code Playgroud)
我从sidekiq wiki获得了这个代码:https: //github.com/mperham/sidekiq/wiki/Monitoring 我尝试了他们发布的代码,但是没有用,所以我做了一些修改,因为我刚发布.上面的代码不起作用,因为用户评估为nil.
处理这个问题的正确安全方法是什么?
谢谢你的帮助!