-1
私は春のフレームワークを学んでいます。私は春には基本的なhello worldプログラムを行いました。実行は約600ミリ秒かけて実行していますパフォーマンスは大きなアプリケーションを構築できます。ここにコードですなぜ単純なコードを実行するのにこのSpringアプリケーションが多くの時間を費やしているのですか
public class MainApp {
@SuppressWarnings("resource")
public static void main(String[] args) {
long time=System.currentTimeMillis();
ApplicationContext context = new ClassPathXmlApplicationContext("Beans.xml");
HelloWorld obj = (HelloWorld) context.getBean("helloWorld");
System.out.println(obj.getMessage());
System.out.println("time in milliseconds"+System.currentTimeMillis()-
time);
}
}
私は上記のコードを依存性注入のためのスプリング構成ファイルで実行しています。なぜ単純なコードのためにこの時間がかかるのですか?ここに出力されます
Nov 22, 2017 10:17:15 PM
org.springframework.context.support.ClassPathXmlApplicationContext
prepareRefresh
INFO: Refreshing
org[email protected]78e03bb5:
startup date [Wed Nov 22 22:17:15 IST 2017]; root of context hierarchy
Nov 22, 2017 10:17:15 PM
org.springframework.beans.factory.xml.XmlBeanDefinitionReader
loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [Beans.xml]
Hello World!
time in milliseconds 656
私は上記のプログラムを実行しています。Windows 7搭載のIntel i3プロセッサ。
Beans.xmlには何がありますか? Springフレームワークは、Dependency Injectionや他の多くのものを容易にするために多くのことを持っています。したがって、開始の遅延。また、Beans.xmlで定義したBeanの数にもよります。 – pvpkiran
はい、コンテキストはアプリケーションの起動時にロードされ、その後は再び実行されません。 –
656ミリ秒は何もありません。大きな市場シェアを持つフレームワークに石を投げること以外に、あなたの人生に役立つ何かをするべきです。 –