我正在编写一个bash脚本来自动化构建过程.有两个主要的构建块,一个是ant任务,一个是普通的mvn clean install.当这两个构建过程中出现构建错误时,我想要做一些事情.
问题是,这些构建将不时包含测试失败或错误,但最终结果是成功的.而且我相信这些进程返回的状态代码($?)应该为0,无论构建失败还是成功,我都错了.
那么,我的脚本检测最终结果(构建失败/成功)的最佳方法是什么,而不会在中间构建(测试错误等)期间捕获错误信息?
我有一个圆角矩形图像,我使用它作为背景的顶部和底部部分:
#content_top { /* 760px by 30px */
background: #F7EECF url(images/content_top_bottom_bg.png) no-repeat 0 0 scroll;
height: 10px;
}
#content_bottom { /* 760px by 30px */
background: #F7EECF url(images/content_top_bottom_bg.png) no-repeat 0 -20px scroll;
height: 10px;
}
Run Code Online (Sandbox Code Playgroud)
然后我使用另一个1px高度的图像垂直重复填充这个div的背景之间的区域.像这样:
#content { /* 760px by 1px */
background: #F7EECF url(images/content_body.png) repeat-y 0 0 scroll;
}
Run Code Online (Sandbox Code Playgroud)
现在我想知道是否可以只使用相同的图像(content_top_bottom.png),但只能使用相同的一部分,以达到同样的效果?我试过这样的东西,但它不起作用:
#content { /* 760px by 1px */
background: #F7EECF url(images/content_top_bottom.png) repeat-y 0 -5px scroll;
}
Run Code Online (Sandbox Code Playgroud)
我想使用相同的图像,因为我想减少http请求的数量.1px图像可能不会产生很大的影响,但我只想尝试一下.谁有人可以帮忙?
我在使用Gson序列化对象时遇到问题.
@XmlRootElement
class Foo implements Serializable {
private int number;
private String str;
public Foo() {
number = 10;
str = "hello";
}
}
Run Code Online (Sandbox Code Playgroud)
Gson会将其序列化为JSON
{"number":10,"str":"hello"}.
但是,我希望它是
{"Foo":{"number":10,"str":"hello"}},
所以基本上包括顶级元素.我试图谷歌一种方式在Gson做到这一点,但没有运气.任何人都知道是否有办法实现这一目标?
谢谢!
我test-jar使用此设置设置了使用普通jar 构建的项目:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
这个问题是每当我升级pom中的项目版本时,我需要使用测试进行构建,否则maven将无法在test-compile短语中找到具有正确版本的测试jar .很多时候我只想跳过测试,但是由于测试罐丢失,这个test-compile短语会失败.
我尝试使用-Dmaven.test.skip=true,但似乎没有跳过这test-compile句话.有没有办法跳过这个?
我从生产代码中得到了这个错误:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:从服务器成功收到的最后一个数据包是36940秒之前.成功发送到服务器的最后一个数据包是36940秒前,这比服务器配置的'wait_timeout'值长.您应该考虑在应用程序中使用之前过期和/或测试连接有效性,增加服务器配置的客户端超时值,或使用Connector/J连接属性"autoReconnect = true"来避免此问题.
而现在我正试图在本地重现问题并修复它.我设置spring上下文如下:
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close" p:driverClass="com.mysql.jdbc.Driver"
p:jdbcUrl="jdbc:mysql://localhost:3306/test?userUnicode=yes&characterEncoding=UTF-8&"
p:idleConnectionTestPeriod="120" p:initialPoolSize="1" p:maxIdleTime="1800"
p:maxPoolSize="1" p:minPoolSize="1" p:checkoutTimeout="1000"
/>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="hibernateProperties">
<value>
hibernate.connection.provider_class = org.hibernate.connection.C3P0ConnectionProvider
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
hibernate.default_schema=platform_server_original
hibernate.show_sql=false
</value>
</property>
<property name="mappingResources">
<list>
<value>sometables.hbm.xml</value>
</list>
</property>
</bean>
Run Code Online (Sandbox Code Playgroud)
然后我将我的mysql wait_timeout设置为10秒,然后运行我的测试,这基本上是打开一个连接,执行查询,关闭它,所以它返回到池中,然后将线程休眠15秒,然后再次打开连接,并再次进行查询,因此它会中断.但是,我只得到了类似的错误:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:通信链接失败
发送到服务器的最后一个数据包是16毫秒前.
所以我想知道这两个错误是一样的,还是它们不同?我做了一些研究,似乎两个错误都归结为同一个解决方案:使用属性"testConnectionOnCheckout = true".但是,根据c3p0 doc,这是一个非常昂贵的检查.它建议使用"idleConnectionTestPeriod",但我已经设置为120秒.我应该使用什么值才能正确验证空闲连接?
所以我基本上要问两件事:1.如何重现生产代码中的错误?2.我该如何解决?
谢谢!
我在javabat中遇到过这个问题(http://www.javabat.com/prob/p183562):
我们想制作一排长达一英寸的砖块.我们有许多小砖(每块1英寸)和大砖(每块5英寸).如果可以通过从给定的砖块中选择来实现目标,则返回true.这比它看起来有点难,可以在没有任何循环的情况下完成.
makeBricks(3,1,8)→true
makeBricks(3,1,9)→false
makeBricks(3,2,10)→true
我想出了这个解决方案:
public boolean makeBricks(int small, int big, int goal) {
if (goal > small + big * 5)
return false;
else if (goal % 5 == 0)
return goal / 5 <= big;
else
return goal % 5 <= small;
}
Run Code Online (Sandbox Code Playgroud)
这通过了测试.但我自己找到了一个反例:makeBricks(10,0,10) - > true.我的逻辑将返回错误.我该如何修复逻辑?或者有更好的方法吗?
我正在使用jersey和jackson来开发我的REST API,并且在反序列化日期字符串时遇到问题.我在泽西岛注册了一个提供者类:
@Provider
public class MyJsonProvider extends JacksonJsonProvider {
public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
@Override
public void writeTo(Object value, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String,Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException {
ObjectMapper mapper = locateMapper(type, mediaType);
// Enable human readable date format
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
mapper.getDeserializationConfig().setDateFormat(sdf);
mapper.getSerializationConfig().setDateFormat(sdf);
// Enable JAXB annotation, with Jackson annotation being the preferred one.
AnnotationIntrospector primary = new JacksonAnnotationIntrospector();
AnnotationIntrospector secondary = new JaxbAnnotationIntrospector();
AnnotationIntrospector introspector = …Run Code Online (Sandbox Code Playgroud) 我在关于GridView的android教程中遵循了这个例子,但是我想要使用TextView简单地显示一些文本,而不是显示图像.结果似乎比我想象的更难.看起来这似乎是完全没必要的,它没有一个有效的用例,但我正在尝试这个让自己熟悉sdk.
所以我的代码与http://developer.android.com/guide/tutorials/views/hello-gridview.html中的GridView示例非常相似,但是我没有使用ImageAdapter,而是创建了一个虚拟适配器,如下所示:
public class MyAdapter extends BaseAdapter {
private Context context;
private String[] texts = {"aaa", "bbb", "ccc", "ddd", "eee", "fff", "eee", "hhh", "iii"};
public MyAdapter(Context context) {
this.context = context;
}
public int getCount() {
return 9;
}
public Object getItem(int position) {
return null;
}
public long getItemId(int position) {
return 0;
}
public View getView(int position, View convertView, ViewGroup parent) {
TextView tv;
if (convertView == null) {
tv = new TextView(context);
tv.setLayoutParams(new GridView.LayoutParams(85, 85)); …Run Code Online (Sandbox Code Playgroud) 我正在尝试在linux中安装adobe air sdk.我将从http://www.adobe.com/products/air/tools/sdk/下载的软件包解压缩到"AdobeAIRSDK"文件夹中,并将/ bin文件夹添加到PATH环境变量中.但是当我试图运行adl时,它给了我以下错误:
加载运行时出错(/home/monuser/AdobeAIRSDK/bin/../runtimes/air/linux/Adobe AIR/Versions/1.0/Resources/nss3/None/libnss3.so:文件太短)
这里有什么问题,如何解决这个问题?
我有一些删除查询来运行一些非常大的表(~100 GB),我想尽可能优化它们:
delete from table1 where column1 < date_sub(now(), interval 100 hour);
Run Code Online (Sandbox Code Playgroud)
column1是一datetime列,我假设为此列创建索引将加速删除.除此之外,我能在这做什么吗?将使用该date_sub()功能减慢查询?我应该在运行查询之前计算该值吗?
delete from table2 where column2 = x;
Run Code Online (Sandbox Code Playgroud)
column2是table2的主键,因此根据mysql文档它已经是一个索引.我的问题是:索引类是PRIMARY,是否与INDEX?相同?我是否必须制作另一种INDEX加速指数?
delete from table3 where column3 = y;
Run Code Online (Sandbox Code Playgroud)
table3有一个复合主键,它是column3和column4.所以我有一个主键索引,但由于删除查询不使用column4,我应该为column3创建一个单独的索引吗?或组合的主键会这样做?
我想这些都是非常基本的问题,但我无法找到特定于我的情况的明确答案,所以任何帮助都将不胜感激!
java ×4
json ×2
mysql ×2
air ×1
android ×1
ant ×1
background ×1
bash ×1
build ×1
c3p0 ×1
compilation ×1
css ×1
gson ×1
hibernate ×1
html ×1
indexing ×1
installation ×1
jackson ×1
jdbc ×1
jersey ×1
linux ×1
logic ×1
maven ×1
maven-2 ×1
optimization ×1
rest ×1
scripting ×1
sdk ×1
skip ×1
spring ×1
sql-delete ×1
testing ×1