我的问题如上.对不起,它可能是重复但我找不到最后的例子<?>
.
你为什么不只是Class
用作参数?
我正在看下面的代码,发现有点奇怪的东西:
public class Sequence {
Sequence() {
System.out.print("c ");
}
{
System.out.print("y ");
}
public static void main(String[] args) {
new Sequence().go();
}
void go() {
System.out.print("g ");
}
static {
System.out.print("x ");
}
}
Run Code Online (Sandbox Code Playgroud)
我希望这会给出一个编译错误,因为System.out
"y"不属于方法声明只是一个{ }
.为什么这个有效?我没有看到这个代码将如何或应该被调用.
当运行它时它也产生x y c g
,为什么static { }
在序列构造函数之前调用get?
默认情况下 - Microsoft SQL Server中数据库的字符编码集是什么?
如何在SQL Server中查看当前字符编码?
这是一个相对开放的问题.如果我在Eclipse中的项目中构建了一个应用程序,然后我想测试这个项目,我应该在同一个项目中创建JUnit代码还是创建一个单独的项目.例如...
ShopSystem
也许是我的主要项目的名称 - 我应该创建一个名为say的项目ShopSystemTest
吗?
一般来说 - 测试代码应该从主项目文件夹中存储多远?如果我将测试代码存储在主项目中,然后将主项目导出为可运行的jar,它将使用它的测试代码,这是不理想的...
建议?
基本上,我已经编写了一个springMVC
应用程序(使用相对猎枪的方式,我的方式是关于Spring的第一次计时器方法).该项目在Tomcat 6上运行正常.我的Tomcat服务器无法启动并抛出以下异常:
Apr 29, 2012 3:41:00 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/bin/jdk1.7.0_03/jre/lib/amd64/server:/usr/bin/jdk1.7.0_03/jre/lib/amd64:/usr/bin/jdk1.7.0_03/jre/../lib/amd64:/usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server:/usr/lib/jvm/java-6-openjdk/jre/lib/amd64:/usr/lib/jvm/java-6-openjdk/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
Apr 29, 2012 3:41:00 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:spring-security-integration' did not find a matching property.
Apr 29, 2012 3:41:00 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Spring3Hibernate' did not find a matching property.
Apr 29, 2012 3:41:00 PM org.apache.tomcat.util.digester.SetPropertiesRule begin …
Run Code Online (Sandbox Code Playgroud) 我已经在Eclipse中添加了位置,因此我可以从SVN位置创建项目.
我不再使用其中一个SVN位置,但是当我从SVN位置转到Team> Create project时,它仍出现在列表中.
如何使用Subclipse从列表中删除此SVN位置?
我正在使用SpringMVC作为Web应用程序以及为Hibernate注入我的sessionFactory.
当我运行我的应用程序时,我收到以下错误...
Apr 29, 2012 3:18:05 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/bin/jdk1.7.0_03/jre/lib/amd64/server:/usr/bin/jdk1.7.0_03/jre/lib/amd64:/usr/bin/jdk1.7.0_03/jre/../lib/amd64:/usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server:/usr/lib/jvm/java-6-openjdk/jre/lib/amd64:/usr/lib/jvm/java-6-openjdk/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
Apr 29, 2012 3:18:05 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:spring-security-integration' did not find a matching property.
Apr 29, 2012 3:18:05 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Spring3Hibernate' did not find a matching property.
Apr 29, 2012 3:18:05 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} …
Run Code Online (Sandbox Code Playgroud) 我有以下代码,我想使输出流使用utf-8.基本上我有像é
这样的字符é
看起来像编码问题.
我见过很多使用的例子......
OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(path),"UTF-8");
Run Code Online (Sandbox Code Playgroud)
我目前的代码是......
BufferedWriter out = new
BufferedWriter(new FileWriter(DatabaseProps.fileLocation + "Output.xml"));
Run Code Online (Sandbox Code Playgroud)
是否可以将此对象定义为UTF-8而无需使用OutputStreamWriter?
谢谢,
我在"tx:annotation-driven"行中得到了上面的错误,但是我已经将命名空间声明在beans文件的顶部,为什么以下的XML会导致此错误?
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<!-- DispatcherServlet Context: defines this servlet's request-processing
infrastructure -->
<!-- Enables the Spring MVC @Controller programming model -->
<tx:annotation-driven transaction-manager="hibernateTransactionManager"/>
<!-- Handles HTTP GET requests for /resources/** by efficiently serving
up static resources in the ${webappRoot}/resources directory -->
<resources mapping="/resources/**" location="/resources/" />
<!-- Resolves views selected for rendering by @Controllers to .jsp resources
in the /WEB-INF/views directory -->
<beans:bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" …
Run Code Online (Sandbox Code Playgroud) 说我用春天,我有以下策略......
接口
public interface MealStrategy {
cook(Meat meat);
}
Run Code Online (Sandbox Code Playgroud)
第一战略
@Component
public class BurgerStrategy implements
MealStrategy {
@Autowired CookerDao cookeryDao;
@Override
public void cook(Meat meat) {
cookeryDao.getBurger(meat);
}
}
Run Code Online (Sandbox Code Playgroud)
下一步策略......
@Component
public class SausageStrategy implements
MealStrategy {
@Autowired CookerDao cookeryDao;
@Override
public cook(Meat meat) {
return cookeryDao.getSausage(meat);
}
}
Run Code Online (Sandbox Code Playgroud)
背景...
@Component
@Scope("prototype")
public class MealContext {
private MealStrategy mealStrategy;
public void setMealStrategy(MealStrategy strategy) {
this.strategy = strategy;
}
public void cookMeal(Meat meat) {
mealStrategy.cook;
}
}
Run Code Online (Sandbox Code Playgroud)
现在说这个上下文是通过mvc控制器访问的,比如...
@Autowired
private MealContext …
Run Code Online (Sandbox Code Playgroud)