在gradle中完成jar任务后我需要签一个jar.我需要从构建中引用生成的jar文件,我可以重新创建jar文件,但我真的想找一个为我做这个的属性.
我是这样做的:
jar.doLast { jarfile = project.libsDir.path + File.separator + project.Name + '-' + project.version + '.jar' ant.signJar(jar: jarfile, .... }
是否有可以用来代替长"路径计算"的属性?
我有一个OSGi包,它使用JAX-RS来处理一些REST服务.该捆绑包使用Apache CXF在Karaf中运行.我需要将基本的http身份验证应用于某些路径/方法组合.我一直在修改Spring Security,看起来新的3.1版本可以让你做到这一点,但是我在使用OSGi时遇到了很多麻烦.
就像测试一样,我创建了一个非常简单的beans.xml文件:
<beans>
<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml"/>
<import resource="classpath:META-INF/cxf/cxf-extension-http.xml"/>
<import resource="classpath:META-INF/cxf/osgi/cxf-extension-osgi.xml"/>
<jaxrs:server id="serverTest" address="/test">
<jaxrs:serviceBeans>
<ref bean="tstSvr"/>
</jaxrs:serviceBeans>
</jaxrs:server>
<bean id="tstSvr" class="com.demo.Test"/>
<security:http auto-config="true">
<security:intercept-url pattern="/admin/**" access="ROLE_ADMIN" method="PUT" />
<security:intercept-url pattern="/**" access="ROLE_USER" />
</security:http>
<security:authentication-manager>
<security:authentication-provider>
<security:user-service>
<security:user name="user" password="pass" authorities="ROLE_USER"/>
<security:user name="admin" password="pass" authorities="ROLE_ADMIN"/>
</security:user-service>
</security:authentication-provider>
</security:authentication-manager>
</beans>
Run Code Online (Sandbox Code Playgroud)
现在,这里有趣的部分...从我一直在做的所有阅读中,我需要一个web.xml来实现这一点.比如我尝试使用的这个示例:
<web-app>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
Run Code Online (Sandbox Code Playgroud)
使用这两个文件的组合不起作用.并且"没有用",我的意思是什么也没发生.没有错误消息,没有异常,捆绑功能就像我尝试添加spring security之前一样.我假设问题是bundle需要是一个WAR或WAB来加载web.xml.它是否正确?
更重要的是,有没有一种方法可以让没有web.xml的春天工作?
我正在假设我需要将捆绑包作为一个捆绑包供CXF加载它,所以我无法将其转换为WAR或WAB,但我并不完全确定是这种情况.
感谢您的任何帮助,您可以提供!
更新:
在做了一堆额外的谷歌搜索后,我发现了一个论坛帖子,提到添加Web-FilterMappings: springSecurityFilterChain;url-patterns:="/*"
到您的清单而不是使用web.xml.但是,您仍然需要使用WAB而不是普通的捆绑包.我已将该行添加到我的清单中以防万一,但它没有任何效果.我的问题似乎转变为:如何在CXF中使用WAB?
更新2: 因为这个问题不够长......我决定尝试使用Spring …
是否有.NET中的API调用或本机DLL,当我的聊天来自某人时,我可以使用它来创建与Windows Live Messenger类似的行为?
我有以下代码适用于Windows XP和Vista - 32位和64位:
public static Icon GetFolderIcon(IconSize size, FolderType folderType)
{
// Need to add size check, although errors generated at present!
uint flags = Shell32.SHGFI_ICON | Shell32.SHGFI_USEFILEATTRIBUTES;
if (FolderType.Open == folderType)
{
flags += Shell32.SHGFI_OPENICON;
}
if (IconSize.Small == size)
{
flags += Shell32.SHGFI_SMALLICON;
}
else
{
flags += Shell32.SHGFI_LARGEICON;
}
// Get the folder icon
var shfi = new Shell32.SHFILEINFO();
Shell32.SHGetFileInfo( null,
Shell32.FILE_ATTRIBUTE_DIRECTORY,
ref shfi,
(uint) Marshal.SizeOf(shfi),
flags );
Icon.FromHandle(shfi.hIcon); // Load the icon from an HICON …
Run Code Online (Sandbox Code Playgroud) 我有一个servlet进行一些错误检查,如果出现问题,我通常会这样做:
response.sendError(403, "My message")
return;
Run Code Online (Sandbox Code Playgroud)
我不希望从servlet抛出一个异常-因为我想用HTTP状态代码一致.
在web.xml中我配置了以下内容:
<error-page>
<error-code>403</error-code>
<location>/failure.jsp</location>
</error-page>
Run Code Online (Sandbox Code Playgroud)
在failure.jsp中我声明了JSTL的用法,我希望显示错误消息.我知道我可以在scriptlet中执行以下操作:
<%= request.getAttribute("javax.servlet.error.message") %>
但我想使用JSTL和一些c:if子句,所以如果我可以使用scriptlet,这将是值得赞赏的.
如何使用JSTL轻松从错误页面中的servlet中的sendError语句中获取值?
我正在使用Windows资源管理器命名空间扩展,它是一个虚拟文件系统.关于这一点,我想支持Windows资源管理器中提供的搜索对话框中的搜索.
目前我能够在我所站的文件夹中按名称进行搜索,但我希望能够在整个结构中以及虚拟文件系统的内容中进行搜索,并且由于Windows资源管理器无法执行此操作,因此我需要挂钩自定义搜索提供程序.
由于它是一个虚拟文件系统,如果我可以编写一个自定义UI来显示结果,这将是有益的,但这不是强制性的.
自定义Explorer命名空间扩展是用C#编写的,但不需要包装API.任何指向API文档,商业产品和/或样本的指针都将受到赞赏.
我知道Wix和PowerShell脚本上有几篇帖子,但在尝试了这些帖子的解决方案之后,我仍然没有得到我想要的结果.为了解释我的情况,我创建了一个Wix安装项目,它将从我的本地机器(运行Windows 7)中获取2个Powershell脚本和一个msu文件,并将它们捆绑到一个msi文件中.如果我在测试虚拟机上运行msi文件(运行Windows Server 2008 r2),文件将被复制到指定的目录中.大.在"添加/删除程序"列表中显示新项目有一个缺点,但这将是我将在以后处理的内容.
(Powershell脚本将安装msu,编辑配置文件并启动服务 - 手动运行时工作正常)
将文件复制到目标计算机后我尝试做的就是运行一个复制的Powershell脚本,但到目前为止我还没能实现这一点.
我的.wxs代码看起来像这样(使用TFS 2010编写和编译)
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Product Id="a89cc681-d617-43ea-817e-1db89b941bf2" Name="Test1" Language="1033" Version="1.0.0.0" Manufacturer="Test1" UpgradeCode="d8db2663-2567-4bb8-9023-09988838eb55">
<Package InstallerVersion="200" Compressed="yes" />
<Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />
<!-- Set up the directory -->
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="IISTIERINSTALLATION" Name="IISTierInstallation">
</Directory>
</Directory>
<!-- Copy the files -->
<DirectoryRef Id="IISTIERINSTALLATION">
<Component Id ="C2WTS_update_file" Guid="11960C39-12EB-4777-B43F-394ADB352DD3">
<File Id="C2WTSmsu" Name="Windows6.1-KB974405-x64.msu" Source="C:\PS Scripts\Windows6.1-KB974405-x64.msu" />
</Component>
<Component Id ="C2WTSInstallScript" Guid="C85ED4DB-BDC1-4DD1-84FE-41D7463C6365">
<File Id="C2WTSscript1" Name="C2WTS_service_install.ps1" Source="C:\PS Scripts\C2WTS_service_install.ps1" />
</Component>
<Component Id ="C2WTSxmlScript" Guid="AF1F85A7-88F7-4BBA-89D9-6817CFAA74F9"> …
Run Code Online (Sandbox Code Playgroud) 我需要应用程序服务器,它是beanstalk实例,在启动时执行一些操作,我想运行一个传递给具有UserData属性的实例的bash脚本,该属性可用于常规EC2实例.
我找到了几个示例CloudFormation模板,它使用常规EC2实例执行此操作,但没有使用Beanstalk的示例.我试图将其添加到应用程序的属性字段中:
"MyApp" : {
"Type" : "AWS::ElasticBeanstalk::Application",
"Properties" : {
"Description" : "MyApp description",
"ApplicationVersions" : [{
...
}],
"UserData" : {
"Fn::Base64" : { "Fn::Join" : ["", [
"#!/bin/bash\n",
"touch /tmp/userdata_sucess\n"
]]
}},
...
Run Code Online (Sandbox Code Playgroud)
我还尝试添加到环境部分:
"MyAppEnv" : {
"Type" : "AWS::ElasticBeanstalk::Environment",
"Properties" : {
"ApplicationName" : { "Ref" : "MyApp" },
"Description" : "MyApp environment description",
"UserData" : {
"Fn::Base64" : { "Fn::Join" : ["", [
"#!/bin/bash\n",
"touch /tmp/userdata_sucess\n"
]]
}},
"TemplateName" : "MyAppConfiguration",
"VersionLabel" : "First Cloud …
Run Code Online (Sandbox Code Playgroud) amazon-ec2 amazon-web-services aws-cloudformation amazon-elastic-beanstalk
我有一个主键列,它是一个INT列,我想更改为BIGINT.我们的测试和生产环境使用MySQL,但是对于单元测试,我们使用嵌入式H2数据库.
我创建了以下Liquibase重构:
...
<changeSet id="1" author="trond">
<modifyDataType tableName="event" columnName="id" newDataType="BIGINT" />
<rollback>
<modifyDataType tableName="event" columnName="id" newDataType="INT" />
</rollback>
</changeSet>
...
Run Code Online (Sandbox Code Playgroud)
重构工作,但当我尝试使用Hibernate将对象持久化到数据库时,我收到以下错误消息(我已经包装了错误消息):
ERROR org.hibernate.util.JDBCExceptionReporter [main]: NULL not allowed for column "ID";
SQL statement: insert into event (id, eventtime, guid, meta, objectguid, originatorid, subtype, type) values (null, ?, ?, ?, ?, ?, ?, '0') [90006-140]
JDBC exception on Hibernate data access:
SQLException for SQL [insert into event (id, eventtime, guid, meta, objectguid, originatorid, subtype, type) values (null, ?, ?, ?, ?, ?, …
Run Code Online (Sandbox Code Playgroud)