add export to c# button
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package com.example.demo;
|
||||
|
||||
import com.example.demo.sub.TestComponent2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
|
||||
@SpringBootApplication
|
||||
public class DemoApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
context.scan("com.example.demo");
|
||||
context.refresh();
|
||||
|
||||
TestComponent ms = context.getBean(TestComponent.class);
|
||||
TestComponent2 ms2 = context.getBean(TestComponent2.class);
|
||||
|
||||
System.out.println("The answer is " + ms.getAnswer() + " " + ms2.getMessage());
|
||||
|
||||
context.close();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.example.demo;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* The component name will be "TestComponent" since it is
|
||||
* not set explicitly like @Component("MyComponent").
|
||||
*/
|
||||
@Component
|
||||
public class TestComponent
|
||||
{
|
||||
public int getAnswer() { return 42; }
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.example.demo.sub;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* The component name will be "TestComponent2" since it is
|
||||
* not set explicitly like @Component("MyComponent2").
|
||||
*/
|
||||
@Component
|
||||
public class TestComponent2
|
||||
{
|
||||
public String getMessage() { return "hello"; }
|
||||
}
|
||||
Reference in New Issue
Block a user