我正在学习使用Springsource Tool Suite(STS)和Spring框架进行开发.我正在尝试用于eclipse的Amazon AWS SDK,并决定将其安装到STS中.当我按照创建一个新的AWS项目时,它将.java文件放在src而不是src/main/java下,当我尝试构建它时,它说
"没有主要"或类似的东西.
但是,当我将AwsConsoleApp.java和AwsCredentials.properties移动到src/main/java然后(默认包)时,我可以将该文件作为Java应用程序运行.
我的问题是,src/main/java- > default package和src - > main 之间有什么区别.我附上了一张图片来澄清事情:

在Eclipse的AVD中,我创建了两个除密度值之外相同的设备.装置1具有abstracted LCD density240; 设备2具有160.两者的分辨率为480x800.
有人可以向我解释为什么设备1屏幕上的元素看起来"更大"吗?由于它们具有相同的分辨率,它们不应该显示相同数量的像素吗?如果有的话,因为设备1具有更高的密度,不应该显示更多的细节/屏幕空间?
设备1
设备2
Screeshots - (点击查看大图)
如上所示,我在两个设备上的随机屏幕位置绘制一个半径为15dp的圆.设备2上的圆圈肯定更小,操作栏也是如此.为什么是这样?
我正在使用hibernate 4版本.尝试使用以下代码保持实体:
if(surveyUserRequestTO!=null){
surveyUser = new SurveyUser();
surveyUser.setAdmin(surveyUserRequestTO.getAdmin());
surveyOrganization = getEntityManager().find(SurveyOrg.class, surveyUserRequestTO.getOrganizationID());
if(surveyOrganization !=null){
surveyUser.setSurveyOrg(surveyOrganization);
}else{
return null;
}
surveyUser.setUserName(surveyUserRequestTO.getUserName());
surveyUser.setUserSurveyID(surveyUserRequestTO.getSurveyUserID());
getEntityManager().persist(surveyUser);
Run Code Online (Sandbox Code Playgroud)
我得到以下例外: -
JBAS014134: EJB Invocation failed on component NewUserDataProvider for
method public
com.alt.survey.user.transport.output.SurveyUserResponseTO
com.alt.survey.user.dataprovider.NewUserDataProvider.createNewUser(com.alt.survey.user.transport.input.SurveyUserRequestTO)
throws java.lang.Exception: javax.ejb.EJBException: Transaction
present on server in Never call (EJB3 13.6.2.6)
Run Code Online (Sandbox Code Playgroud)
我相信它与TransactionAttribute属性有关.任何可能的帮助都将非常值得注意.
我见过Sitemesh与Spring和Freemarker(FTL)一起使用.所以我想知道什么是Sitemesh及其与FTL的使用,例如.
我是JavaScript新手。您能否解释一下,为什么我们有两个功能相同?两者的目的是什么?
ToNumber("100");
Run Code Online (Sandbox Code Playgroud)
和
Number("100");
Run Code Online (Sandbox Code Playgroud) 我想用于我的新项目BabelJS,但我有一个很大的要求:它必须在IE8上可执行.
问题:Babel将ES6编译为ES5.IE8对ES5的支持很差.
你知道Babel的替代品,允许我编写"OOP"代码,易于调试和"IE8友好"吗?
javascript internet-explorer-8 coffeescript typescript babeljs
我需要一个应该验证它应该包含至少一个字母表(AZ,az)和可选的数字(0-9)的正则表达式.
有效名称:
名称无效,
到目前为止我试过的正则表达式
[a-zA-Z0-9\.\'\-_\s]{1,20}
Run Code Online (Sandbox Code Playgroud)
和
function validateFirstName(a) {
if (/[0-9]/.test(a) && /[a-zA-Z]/.test(a)) {
return false;
} else {
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
但两者都不起作用.
任何人都可以帮助这方面吗?
我有一个带有 mybatis 3.3.0 和 mybatis-spring 1.2.3 的 Spring MVC 项目,我想在我的项目中配置 log4j 。我不用于mybatis-config.xml设置 mybatis sql 会话工厂。所以我不能使用以下设置,
<configuration>
<settings>
...
<setting name="logImpl" value="LOG4J"/>
...
</settings>
</configuration>
Run Code Online (Sandbox Code Playgroud)
所以,我的配置中有以下配置
spring-context.xml ,
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="typeAliasesPackage" value="com.sample.model"/>
<property name="mapperLocations" value="classpath*:com/sample/mappers/*.xml" />
</bean>
<bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg index="0" ref="sqlSessionFactory" />
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.sample.mappers" />
</bean>
Run Code Online (Sandbox Code Playgroud)
并配置了这个log4j.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN" "log4j.dtd">
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
<appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" …Run Code Online (Sandbox Code Playgroud) //just copied this code from w3schools
var person={fname:"John",lname:"Doe",age:25};
for (x in person)
{
document.write(person[x] + " ");
}
Run Code Online (Sandbox Code Playgroud)
我想知道,我必须假设而不是"x".
我注意到java.lang.Boolean类存在一个无法解析空值的问题.我知道它有parseBoolean静态方法但是因为它的签名状态它只接受String而不是Object.
换句话说,它具有以下特征:
public static boolean parseBoolean(String s)
Run Code Online (Sandbox Code Playgroud)
但不是:
Boolean.parseBoolean(Object)
Run Code Online (Sandbox Code Playgroud)
在不降低NullPointerException的情况下检查布尔值的最佳方法是什么?
如何测试我的个人资料?
那是我的考验
@Test
public void testDevProfile() throws Exception {
System.setProperty("spring.profiles.active", "dev");
Application.main(new String[0]);
String output = this.outputCapture.toString();
Assert.assertTrue(output.contains("The following profiles are active: dev"));
}
@Test
public void testUatProfile() throws Exception {
System.setProperty("spring.profiles.active", "uat");
Application.main(new String[0]);
String output = this.outputCapture.toString();
Assert.assertTrue(output.contains("The following profiles are active: uat"));
}
@Test
public void testPrdProfile() throws Exception {
System.setProperty("spring.profiles.active", "prd");
Application.main(new String[0]);
String output = this.outputCapture.toString();
Assert.assertFalse(output.contains("The following profiles are active: uat"));
Assert.assertFalse(output.contains("The following profiles are active: dev"));
Assert.assertFalse(output.contains("The following profiles are active: default"));
} …Run Code Online (Sandbox Code Playgroud) javascript ×4
java ×2
android ×1
babeljs ×1
boolean ×1
coffeescript ×1
dpi ×1
eclipse ×1
for-in-loop ×1
for-loop ×1
freemarker ×1
hibernate ×1
log4j ×1
logging ×1
mybatis ×1
pixels ×1
regex ×1
resolution ×1
sitemesh ×1
spring ×1
spring-boot ×1
spring-mvc ×1
testing ×1
typescript ×1
unit-testing ×1