我有application.yml,application-dev.yml和application-dev.yml
mvn spring-boot:run -Dspring.profiles.active=dev它不起作用,我不能选择使用开发配置文件mvn spring-boot:run.我该如何选择?java -jar XXX.jar --spring.profiles.active=dev工作,我尝试-Dspring.profiles.active=dev但它不起作用.在我的项目中,我使用java -jar XXX.jar它运行,但如果我java -jar XXX.jar --spring.profiles.active=dev用来选择开发配置文件,控制台打印这么多日志并警告我从未见过用过java -jar XXX.jar,并告诉我APPLICATION FAILED TO START 那么如何解决两个问题呢?谢谢〜
我正在尝试实现细粒度访问控制,同时仍然利用Spring数据休息.
我正在努力确保安全,CrudRepository因此用户只能修改或插入属于他们的数据.我正在使用@PreAuthorize/ @PostAuthorize和@PreFilter/ @PostFilter将访问锁定到当前主体.
到目前为止我的存储库看起来像这样
public interface MyRepository extends CrudRepository<MyObject, Integer> {
@PreAuthorize("#entity.userId == principal.id")
@Override
<S extends MyObject> S save(S entity);
@PreFilter("filterObject.userId === principal.id")
@Override
<S extends MyObject> Iterable<S> save(Iterable<S> entities);
@PostAuthorize("returnObject.userId == principal.id")
@Override
MyObject findOne(Integer integer);
@PostFilter("filterObject.userId == principal.id")
@Override
Iterable<MyObject> findAll();
}
Run Code Online (Sandbox Code Playgroud)
虽然这有点单调乏味,但它似乎完成了我所追求的目标.(如果有人知道更好的方式,请随时告诉我!)
我遇到问题的地方是delete(),count()和exists()
@Override
long count();
@Override
void delete(Integer integer);
@Override
void delete(MyObject entity);
@Override
void deleteAll();
@Override
boolean exists(Integer integer);
Run Code Online (Sandbox Code Playgroud)
这些方法要么采用 …
我正在尝试使用DynamoDB流和AWS提供的Java DynamoDB流Kinesis适配器捕获DynamoDB表更改.我正在使用Scala应用程序中的AWS Java SDK.
我首先遵循AWS指南并浏览AWS发布的代码示例.但是,我遇到了在我的环境中使用亚马逊自己发布的代码的问题.我的问题在于KinesisClientLibConfiguration对象.
在示例代码中,KinesisClientLibConfiguration配置了DynamoDB提供的流ARN.
new KinesisClientLibConfiguration("streams-adapter-demo",
streamArn,
streamsCredentials,
"streams-demo-worker")
Run Code Online (Sandbox Code Playgroud)
我在我的Scala应用程序中遵循类似的模式,首先从我的Dynamo表中找到当前的ARN:
lazy val streamArn = dynamoClient.describeTable(config.tableName)
.getTable.getLatestStreamArn
Run Code Online (Sandbox Code Playgroud)
然后KinesisClientLibConfiguration使用提供的ARN 创建:
lazy val kinesisConfig :KinesisClientLibConfiguration =
new KinesisClientLibConfiguration(
"testProcess",
streamArn,
defaultProviderChain,
"testWorker"
).withMaxRecords(1000)
.withRegionName("eu-west-1")
.withMetricsLevel(MetricsLevel.NONE)
.withIdleTimeBetweenReadsInMillis(500)
.withInitialPositionInStream(InitialPositionInStream.TRIM_HORIZON)
Run Code Online (Sandbox Code Playgroud)
我已经验证了提供的流ARN,所有内容都与我在AWS控制台中看到的相匹配.
在运行时,我最终得到一个异常,说明提供的ARN不是有效的流名称:
com.amazonaws.services.kinesis.clientlibrary.lib.worker.ShardSyncTask call
SEVERE: Caught exception while sync'ing Kinesis shards and leases
com.amazonaws.services.kinesis.model.AmazonKinesisException: 1 validation
error detected: Value 'arn:aws:dynamodb:eu-west-1:STREAM ARN' at
'streamName' failed to satisfy constraint: Member must satisfy regular
expression pattern: [a-zA-Z0-9_.-]+ …Run Code Online (Sandbox Code Playgroud) java scala amazon-web-services amazon-dynamodb amazon-kinesis
我试图使用休眠4的实体一级@Filter的同春数据仓库一个春天启动项目内.我的最终目标是使用比Hibernate @Where注释更灵活的东西来实现通用软删除.
经过一番努力,我已经找到了一个可能天真的解决方案,可以用一个来处理 @Aspect
我设置了一个Spring托管方面,目的是拦截对共享的调用EntityManager并启用适当的过滤器.
我玩了几个不同的切入点,看起来execution(public * javax.persistence.EntityManager.find(..))是一个绑定这个建议的好地方.
@Aspect
@Component
public class HibernateFilterInterceptor {
private final EntityManager entityManager;
private final PlatformTransactionManager platformTransactionManager;
@Autowired
public HibernateFilterInterceptor(EntityManager entityManager, PlatformTransactionManager platformTransactionManager) {
this.entityManager = entityManager;
this.platformTransactionManager = platformTransactionManager;
}
@Before("execution(public * javax.persistence.EntityManager.find(..))")
public void beforeFind(){
}
Run Code Online (Sandbox Code Playgroud)
从Hibernate docs/examples看来,我应该能够使用类似的东西来启用过滤器 entityManager.unwrap(Session.class).enableFilter("filter").setParameter("foo", 1);
所以测试我在单个实体上定义了一个简单的过滤器.
@FilterDef(name = "status", parameters = @ParamDef(name = "status", type = "integer"))
@Filters(
@Filter(name = "status", condition = ":status = status")
)
public class …Run Code Online (Sandbox Code Playgroud) 我于2014年1月24日在iOS App Store中发送了一个应用程序.这是一款仅限iO7/iPhone的应用程序,一切都正确交付.截至昨天,我的应用程序已获批准,目前可在App Store中看到.
我整理了一个小小的更新,目前正在使用Application Loader进行交付.
但是,现在当我上传我的生产IPA时,由于看起来像是一个sdk错误而被拒绝了.
Messages:
Apple's web service operation was not successful
Unable to authenticate the package: 806906410.itmsp
ERROR ITMS-9000: "This bundle is invalid. Apple is not currently accepting applications built with this version of the SDK." at SoftwareAssets/SoftwareAsset (MZItmspSoftwareAssetPackage)
Run Code Online (Sandbox Code Playgroud)
我正在努力弄清楚自从我使用与上周末相同的SDK构建以来发生了什么变化.
我正在创建一个DynamoDB表来保存与单个对象关联的注释.
评论在特定时间发布到对象,我使用发布的时间作为范围,因此评论按时间降序排序.我有一个发布评论的用户的userId的全局二级索引,这应该允许我获取给定用户发布的所有评论.
我的问题是,这个密钥是否独一无二?我担心,因为技术上两个用户可以同时向同一个objectId发布评论,所以评论散列和范围键将是相同的.
我的希望是,由于同一个用户不可能同时在同一个对象上发布两条评论,因此全局二级索引将使密钥唯一.
Comment table:
Hash Key Range Key Global Secondary Index Hash
---------------------------------------------------------------------------------------
| objectId | datePosted | userId |
| (not unique) | (not unique if multiple users | (unique across objectId and |
| | post for the same object @ same time) | datePosted) |
---------------------------------------------------------------------------------------
Run Code Online (Sandbox Code Playgroud) 我有一个REST-full Web服务,使用Spring Boot 1.2.0-RELEASE实现,偶尔会在启动时抛出以下异常.
03-Feb-2015 11:42:23.697 SEVERE [localhost-startStop-1] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
...
Caused by: java.lang.IllegalStateException: Duplicate Filter registration for 'springSecurityFilterChain'. Check to ensure the Filter is only configured once.
at org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer.registerFilter(AbstractSecurityWebApplicationInitializer.java:215)
at org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer.insertSpringSecurityFilterChain(AbstractSecurityWebApplicationInitializer.java:147)
...
Run Code Online (Sandbox Code Playgroud)
当我说"偶尔"时,我的意思是简单地重新启动Tomcat服务器(版本8.0.17)将产生此异常或将成功加载而不会出现问题.
这是一个基于Spring Boot构建的Servlet 3.0应用程序,因此我们没有传统的web.xml文件.相反,我们使用Java初始化我们的servlet.
package com.v.dw.webservice;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
public class WebXml extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(ApplicationConfig.class);
}
}
Run Code Online (Sandbox Code Playgroud)
我们还在mvn spring-boot:run开发期间利用该命令,并且在以这种方式运行时尚未出现此竞争条件.我们的配置的"根"和maven使用的主要方法在同一个类中:
package com.v.dw.webservice;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Value; …Run Code Online (Sandbox Code Playgroud) 我有一组非托管类,我在Spring之外实例化.我一直在尝试使用Spring AOP将加载时间编织@Autowire到这些类的bean中,但到目前为止还没有任何运气.
我一直在使用Tomcat 8和Spring Boot 1.2.0进行测试.
我@Configuration尝试设置类的位置如下所示:
@Configuration
@PropertySource("classpath:application.properties")
@EnableSpringConfigured
@EnableLoadTimeWeaving
public class Config
Run Code Online (Sandbox Code Playgroud)
在里面Config我将我想要的bean定义@Auotwire到我的非托管类中:
@Bean
public StateProvider stateProvider() {
//setup bean
return new DynamoStateProviderImpl( );
}
Run Code Online (Sandbox Code Playgroud)
非托管bean看起来像这样:
@Configurable(autowire = Autowire.BY_TYPE, dependencyCheck = true, preConstruction = true)
public class StateOutput implements UnifiedOutput {
@Autowired
private StateProvider stateProvider;
Run Code Online (Sandbox Code Playgroud)
我的pom内有以下deps
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-agent</artifactId>
<version>2.5.6.SEC03</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>3.0.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
到目前为止,我还没有看到任何注入stateProvider …
我目前正在努力解决一个远远超出我数学能力的问题(自从我做了一些正确的数学以来已经很长时间了......)我会很感激一些帮助.
这是我的设置:我有一些简单的形状(矩形),我将它们的底点"投射"在一条线上,来自Origin点.到目前为止,一切都很好.但是现在我想把原始的形状画成扭曲的,好像是在平面上用一些透视投影的.
请考虑我的代码中没有任何与旋转,等距或任何3D或假2D视角相关的内容,我只是尝试使用图形库绘制一些形状,只有真实的感觉.
这是我正在尝试做的快速绘图:

我知道的 :
我想要确定的是C&D点的坐标,如果我没有努力找到"Origin bis"坐标,这可能很容易.
我想要做的是伪造我的矩形投影在可以被视为"地板"的东西上(与我的原始矩形可以看作墙壁的平面相关).
也许我过度复杂化问题或者我没有看到任何其他更简单的方法来做到这一点,但我在任何几何或数学方面都不再好...... :-(
非常感谢你的回答 !
我正在尝试提供一个解决方案,用于在焦点进入文本字段时设置通知.最终目标是重新创建您在屏幕键盘的移动设备上看到的功能类型.
到目前为止,我一直在探索SetWinEventHook用EVENT_OBJECT_FOCUS 和GetGUIThreadInfo用GUI_CARETBLINKING.
来自文档:
EVENT_OBJECT_FOCUS
对象已收到键盘焦点.系统为以下用户界面元素发送此事件:列表视图控件,菜单栏,弹出菜单,切换窗口,选项卡控件,树视图控件和窗口对象.
GUI_CARETBLINKING插入符号的闪烁状态.如果插入符号可见,则设置此位.
使用这些方法,我提出了这个解决方案:
void TextInputHelper::setupEventHook(FREContext iCtx)
{
ctx = iCtx;
CoInitialize(NULL);
evHook = SetWinEventHook(EVENT_OBJECT_FOCUS, EVENT_OBJECT_END, NULL,
handleEventObjectFocus, 0, 0,
WINEVENT_OUTOFCONTEXT | WINEVENT_SKIPOWNPROCESS);
}
void CALLBACK handleEventObjectFocus(HWINEVENTHOOK hook, DWORD evt, HWND hwnd,
LONG idObj, LONG idChild, DWORD thread, DWORD time)
{
GUITHREADINFO threadInfo;
threadInfo.cbSize = sizeof(GUITHREADINFO);
BOOL result = GetGUIThreadInfo(thread, &threadInfo);
if(threadInfo.flags & GUI_CARETBLINKING)
{
//text field focus
}
}
Run Code Online (Sandbox Code Playgroud)
这似乎在某些情况下有效,但它绝对不可靠.像Notepad和IE这样的程序似乎工作得很好,但像Firefox这样的程序却没有.这也不适用于网站上的文本字段之类的内容,因为它看起来handleEventObjectFocus不会被调用.
有谁知道另一种方法来解决这个问题?我一直在寻找,似乎我可能正在寻找辅助功能API中的东西,但我还没有深入了解它.
谢谢!
编辑
为了澄清,我希望在焦点进入任何文本字段时收到通知.这个应用程序是一个win32 dll,永远不会集中精力.
我正在尝试UIViewController使用AirPlay在外部显示器上以16:9显示全屏.
此处的目标是使用自定义视图控制器替换AirPlay镜像,该控制器将跨越外部屏幕的整个大小.
当iPad处于纵向模式时,屏幕连接时,一切似乎都很好.当它以横向连接时,在UIViewController外部显示器上侧向显示并且仅填充屏幕的一半.
为此,我将我添加UIViewController到附加的AirPlay中UIScreen.
-(void) screenConnected:(NSNotification * ) notification {
UIScreen * screen = [notification object]; //this should be the airplay display
UIWindow * window = [[UIWindow alloc] initWithFrame:screen.bounds];
[currentWindow setScreen:screen];
UIViewController * controller = [_delegate createControllerForAirplayDisplay:window];
[window setHidden:NO];
[window setRootViewController:controller];
}
Run Code Online (Sandbox Code Playgroud)
这似乎工作正常,我看到iPad和AirPlay电视全屏显示.
我在哪里看到的问题是当iPad处于横向模式时连接AirPlay显示器.当发生这种情况时,AirPlay显示屏会呈现UIViewController侧面和看起来像肖像模式.
屏幕连接为纵向:

屏幕连接在横向,内容是侧面的,只在一半的显示器上呈现:

我试图旋转UIWindow和UIViewController使用CGAffineTransformMakeRotation,这确实修复了方向,但视图没有在AirPlay显示内部居中.
编辑
提起与此相关的Apple问题,rdar:// 20817189.如果/当我收到回复时,我会更新此信息.
我想要提出一些正则表达式,它将从字符串中删除所有空格字符,只要它不在双引号(")内.
示例字符串:
带有"引号中的文字"的字符串
结果:
somestringwith"引号中的文字"
到目前为止,我想出了类似的东西:
$str =~ /"[^"]+"|/g;
Run Code Online (Sandbox Code Playgroud)
但它似乎没有给出预期的结果.
老实说,我非常擅长perl而且没有太多的正则表达式经验.因此,如果有人愿意回答,也愿意提供一些有关为什么以及如何做到这一点的洞察力!
谢谢!
编辑
字符串不包含转义符号
它实际上应该始终格式如下:
Some.String ="有些价值"
结果将是
Some.String ="有些价值"