目前,我正在使用@SpringBootApplication具有以下属性的默认注释application.properties:
spring.datasource.url=jdbc:mysql://localhost/dbname
spring.datasource.username=X
spring.datasource.password=X
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.hibernate.naming_strategy=my.package.CustomNamingStrategy
Run Code Online (Sandbox Code Playgroud)
从JPA 2.1开始,我应该可以使用这些javax.persistence.schema-generation.*属性,但是在我的application.properties中设置它们似乎没有任何效果.
我见过的例子是这样那丝了一大堆额外的豆子,但他们没有使用MySQL.无论如何,这样做需要我配置春天为我提供的许多选项.
我的目标是:
我不想:
Lib版本:
hibernate : 4.3.11.FINAL
spring framework : 4.2.5.RELEASE
spring-boot : 1.3.3.RELEASE
spring-data-jpa : 1.10.1.RELEASE // for querydsl 4 support
spring-data-commons: 1.12.1.RELEASE // for querydsl 4 support
Run Code Online (Sandbox Code Playgroud)
(使用gradle,而不是maven)
本着/sf/ask/234499331/的精神
Linux有哪些优秀的代码片段管理器?
我的快速搜索没有发现太多.Eclipse,emacs,vim,Kate和KDevelop都提供了自己的集成代码片段管理器,但我正在寻找一些更通用的CodeCollector或Snippets,理想情况下可以选择CLI接口.
即使是纯粹的CLI工具也是可以接受的(甚至可能更好).
我有一个脚本的Perl片段,我正在翻译成Python.我不知道"s!" 操作员正在做; 某种正则表达式替换.不幸的是,搜索谷歌或Stackoverflow这样的运营商并没有产生很多有用的结果.
$var =~ s!<foo>.+?</foo>!!;
$var =~ s!;!/!g;
Run Code Online (Sandbox Code Playgroud)
每条线路做什么?我想知道以防我再次遇到这个操作员.
而且,Python中的等效语句是什么?
我正在尝试将阿拉伯文字绘制到位图上以供显示:
Bitmap img = Bitmap.createBitmap( (int) f+100, 300, Config.RGB_565);
Canvas c = new Canvas();
c.setBitmap( img );
mFace = Typeface.createFromAsset(getAssets(),"DejaVuSansCondensed.ttf");
mPaint.setTypeface(mFace);
content = "????";
content = ArabicUtilities.reshape( content );
System.out.println("Drawing text: " + content);
c.drawText(content, 30, 30, mPaint);
Run Code Online (Sandbox Code Playgroud)
ArabicUtilities类是一个重塑unicode文本的工具,因此字母是连接的.请参阅:http://github.com/agawish/Better-Arabic-Reshaper/
但是,生成的位图如下所示:
alt text http://imagebin.ca/img/J1EB8DWc.jpg
它应该看起来像يجري
我相信这个问题是因为,与TextView不同,Bitmap类不支持BiDi,所以它从左边开始绘制字母.
尽我所能,我无法弄清楚如何以正确的顺序绘制文本.
我正在使用带有弹簧启动的tapestry 5,使用这个很棒的小库:https://github.com/code8/tapestry-boot
然而,尽管我使用了OpenSesionInViewFilter,但我得到了臭名昭着的LazyInitializationException.除了OpenSesionInViewFilter的优点和缺点之外,我还想在OpenSesionInViewFilter中使用它,因为我正在移植一个大型遗留应用程序.
我的春季启动配置是
@SpringBootApplication
public class Launcher {
public static void main(String[] args) {
new SpringApplicationBuilder(Launcher.class)
.web(true)
.run(args);
}
@Bean
public HibernateJpaSessionFactoryBean sessionFactory() {
return new HibernateJpaSessionFactoryBean();
}
@Bean
public FilterRegistrationBean registerOpenSessionInViewFilterBean() {
FilterRegistrationBean registrationBean = new FilterRegistrationBean();
OpenSessionInViewFilter filter = new OpenSessionInViewFilter();
registrationBean.setFilter(filter);
registrationBean.setOrder(5);
return registrationBean;
}
}
Run Code Online (Sandbox Code Playgroud)
我已经确保在TapestryFilter之前加载了OpenSessionInViewFilter,并在启动时通过spring的输出验证了这一点.我在TapestryFilter上编辑了tapestry-boot库到setOrder(10).
我还通过调试验证了OpenSessionInViewFilter实际上正在创建一个会话.
在下面的LIE的示例堆栈跟踪中,您可以看到正在使用OpenSessionInViewFilter.
我有2级服务层:
Tapestry Pages --> XXManagerImpl (e.g, UserManager) --> JpaRepository
Run Code Online (Sandbox Code Playgroud)
我的经理服务注释如下:
@Service
@Transactional(propagation = Propagation.REQUIRED)
public class UserManagerImpl implements UserManager, Serializable
Run Code Online (Sandbox Code Playgroud)
我的JpaRepositories没有注释@Transactional和@Repository(如果它很重要).
初始数据访问按预期工作,但是当我尝试访问Lazy初始化字段时,我得到了LIE.
根异常:
Caused …Run Code Online (Sandbox Code Playgroud) 我的应用程序由两个线程组成:
我使用两个线程的原因是保持GUI响应,同时让Sim线程尽可能快地旋转.
在我的GUI线程中,我在SIM卡中以30-60的FPS渲染实体; 但是,我希望我的SIM卡能够"紧缩" - 可以这么说 - 并最终排队游戏状态(想想流媒体视频,你有一个缓冲区).
现在,对于我渲染的每个帧,我需要相应的模拟"状态".所以我的sim线程看起来像:
while(1) {
simulation.update();
SimState* s = new SimState;
simulation.getAgents( s->agents ); // store agents
// store other things to SimState here..
stateStore.enqueue(s); // stateStore is a QQueue<SimState*>
if( /* some threshold reached */ )
// push stateStore
}
Run Code Online (Sandbox Code Playgroud)
SimState 好像:
struct SimState {
std::vector<Agent> agents;
//other stuff here
};
Run Code Online (Sandbox Code Playgroud)
而Simulation :: getAgents看起来像:
void Simulation::getAgents(std::vector<Agent> &a) const
{
// mAgents is a std::vector<Agent>
std::vector<Agent> a_tmp(mAgents);
a.swap(a_tmp);
}
Run Code Online (Sandbox Code Playgroud)
这Agent本身就是一些复杂的课程.成员是一堆 …
我的目标是获得一个简单的facej + spring aop设置,这样我就可以在一个类上使用@Configurable.另一个限制是它需要使用加载时编织,因为Lombok不能与CTW一起使用.
好消息:我有它的工作!
坏消息:控制台充斥着[Xlint:cantFindType]错误.见下面的结果部分.
我有一个单独的类注释@Configurable.它是杰克逊使用和实例化的一个类,因此需要AOP.它不是很有趣所以我不会在这里展示它.它只是一个普通的类,带有Configurable的单个注释,@Autowired里面有一个bean.
我的Application类具有通常的注释:
@SpringBootApplication
@EnableSpringConfigured
@EnableLoadTimeWeaving
public class MyApplication {
Run Code Online (Sandbox Code Playgroud)
我的build.gradle有所有常见的嫌疑人.样品:
configurations {
springinstrument
}
dependencies {
compile('org.projectlombok:lombok')
compile('org.springframework.boot:spring-boot-starter-aop')
compile("org.springframework.boot:spring-boot-starter-data-rest")
compile('org.springframework.data:spring-data-rest-hal-browser')
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-security')
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-devtools')
compile('org.springframework.plugin:spring-plugin:1.2.0.RELEASE')
..snip..
runtime('org.springframework:spring-instrument:4.+')
springinstrument "org.springframework:spring-instrument:4.+"
runtime configurations.springinstrument.dependencies
}
test.doFirst {
jvmArgs "-javaagent:${configurations.springinstrument.asPath}"
}
Run Code Online (Sandbox Code Playgroud)
我正在使用以下args运行JUnit测试(通过Intellij的运行配置)
-ea
-javaagent:/Users/me/.gradle/caches/modules-2/files-2.1/org.springframework/spring-instrument/4.3.3.RELEASE/5db399fa5546172b9c107817b4abaae6b379bb8c/spring-instrument-4.3.3.RELEASE.jar
Run Code Online (Sandbox Code Playgroud)
我有一个src/main/resources/META-INF/aop.xml包含:
<!DOCTYPE aspectj PUBLIC "-//AspectJ//DTD//EN" "http://www.eclipse.org/aspectj/dtd/aspectj.dtd">
<aspectj>
<weaver options="-Xreweavable -showWeaveInfo">
<!-- only weave classes with @Configurable interface -->
<include within="@org.springframework.beans.factory.annotation.Configurable …Run Code Online (Sandbox Code Playgroud) spring-boot ×3
hibernate ×2
spring-data ×2
android ×1
bidi ×1
c++ ×1
gradle ×1
linux ×1
performance ×1
perl ×1
python ×1
qt ×1
regex ×1
simulation ×1
spring ×1
spring-aop ×1
tapestry ×1