diff --git a/Test8-EL/.idea/compiler.xml b/Test8-EL/.idea/compiler.xml new file mode 100644 index 00000000..9349b67f --- /dev/null +++ b/Test8-EL/.idea/compiler.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Test8-EL/.idea/copyright/profiles_settings.xml b/Test8-EL/.idea/copyright/profiles_settings.xml new file mode 100644 index 00000000..e7bedf33 --- /dev/null +++ b/Test8-EL/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/Test8-EL/.idea/libraries/Maven__commons_io_commons_io_2_5.xml b/Test8-EL/.idea/libraries/Maven__commons_io_commons_io_2_5.xml new file mode 100644 index 00000000..67c2ad2c --- /dev/null +++ b/Test8-EL/.idea/libraries/Maven__commons_io_commons_io_2_5.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Test8-EL/.idea/libraries/Maven__commons_logging_commons_logging_1_2.xml b/Test8-EL/.idea/libraries/Maven__commons_logging_commons_logging_1_2.xml new file mode 100644 index 00000000..eab40b32 --- /dev/null +++ b/Test8-EL/.idea/libraries/Maven__commons_logging_commons_logging_1_2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Test8-EL/.idea/libraries/Maven__org_springframework_spring_aop_4_3_3_RELEASE.xml b/Test8-EL/.idea/libraries/Maven__org_springframework_spring_aop_4_3_3_RELEASE.xml new file mode 100644 index 00000000..9e08177c --- /dev/null +++ b/Test8-EL/.idea/libraries/Maven__org_springframework_spring_aop_4_3_3_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Test8-EL/.idea/libraries/Maven__org_springframework_spring_beans_4_3_3_RELEASE.xml b/Test8-EL/.idea/libraries/Maven__org_springframework_spring_beans_4_3_3_RELEASE.xml new file mode 100644 index 00000000..1ddd8b9b --- /dev/null +++ b/Test8-EL/.idea/libraries/Maven__org_springframework_spring_beans_4_3_3_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Test8-EL/.idea/libraries/Maven__org_springframework_spring_context_4_3_3_RELEASE.xml b/Test8-EL/.idea/libraries/Maven__org_springframework_spring_context_4_3_3_RELEASE.xml new file mode 100644 index 00000000..fbc79eb4 --- /dev/null +++ b/Test8-EL/.idea/libraries/Maven__org_springframework_spring_context_4_3_3_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Test8-EL/.idea/libraries/Maven__org_springframework_spring_core_4_3_3_RELEASE.xml b/Test8-EL/.idea/libraries/Maven__org_springframework_spring_core_4_3_3_RELEASE.xml new file mode 100644 index 00000000..cabb772e --- /dev/null +++ b/Test8-EL/.idea/libraries/Maven__org_springframework_spring_core_4_3_3_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Test8-EL/.idea/libraries/Maven__org_springframework_spring_expression_4_3_3_RELEASE.xml b/Test8-EL/.idea/libraries/Maven__org_springframework_spring_expression_4_3_3_RELEASE.xml new file mode 100644 index 00000000..200454c0 --- /dev/null +++ b/Test8-EL/.idea/libraries/Maven__org_springframework_spring_expression_4_3_3_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Test8-EL/.idea/misc.xml b/Test8-EL/.idea/misc.xml new file mode 100644 index 00000000..233a7f02 --- /dev/null +++ b/Test8-EL/.idea/misc.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Test8-EL/.idea/modules.xml b/Test8-EL/.idea/modules.xml new file mode 100644 index 00000000..5ed06309 --- /dev/null +++ b/Test8-EL/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Test8-EL/.idea/uiDesigner.xml b/Test8-EL/.idea/uiDesigner.xml new file mode 100644 index 00000000..e96534fb --- /dev/null +++ b/Test8-EL/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Test8-EL/.idea/workspace.xml b/Test8-EL/.idea/workspace.xml new file mode 100644 index 00000000..b5cb8f92 --- /dev/null +++ b/Test8-EL/.idea/workspace.xml @@ -0,0 +1,996 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + DEFINITION_ORDER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + project + + + + + + + + + + + + + + + + project + + + true + + + + DIRECTORY + + false + + + + + + + + + + + + + + + + + + + + + + + 1481611704346 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Test8-EL/Test8-EL.iml b/Test8-EL/Test8-EL.iml new file mode 100644 index 00000000..04dd8efd --- /dev/null +++ b/Test8-EL/Test8-EL.iml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Test8-EL/pom.xml b/Test8-EL/pom.xml new file mode 100644 index 00000000..44e84a5c --- /dev/null +++ b/Test8-EL/pom.xml @@ -0,0 +1,23 @@ + + + 4.0.0 + + Test8-EL + Test8-EL + 1.0-SNAPSHOT + + + org.springframework + spring-context + 4.3.3.RELEASE + + + commons-io + commons-io + 2.5 + + + + \ No newline at end of file diff --git a/Test8-EL/src/main/java/org/sang/DemoService1.java b/Test8-EL/src/main/java/org/sang/DemoService1.java new file mode 100644 index 00000000..544bb350 --- /dev/null +++ b/Test8-EL/src/main/java/org/sang/DemoService1.java @@ -0,0 +1,22 @@ +package org.sang; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + +/** + * Created by sang on 16-12-13. + */ +@Service +public class DemoService1 { + //注入普通字符串 + @Value("老王") + private String author; + + public String getAuthor() { + return author; + } + + public void setAuthor(String author) { + this.author = author; + } +} diff --git a/Test8-EL/src/main/java/org/sang/ELConfig.java b/Test8-EL/src/main/java/org/sang/ELConfig.java new file mode 100644 index 00000000..c1f61c31 --- /dev/null +++ b/Test8-EL/src/main/java/org/sang/ELConfig.java @@ -0,0 +1,65 @@ +package org.sang; + +import org.apache.commons.io.IOUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.core.env.Environment; +import org.springframework.core.io.Resource; + +import java.io.IOException; + +/** + * Created by sang on 16-12-13. + */ +@Configuration +@ComponentScan("org.sang") +@PropertySource(value = "t.properties",encoding = "UTF-8") +public class ELConfig { + @Value("I Love You!") + private String normal; + @Value("#{systemProperties['os.name']}") + private String osName; + @Value("#{systemEnvironment['os.arch']}") + private String osArch; + @Value("#{T(java.lang.Math).random()*100}") + private double randomNumber; + @Value("#{demoService1.author}") + private String author; + @Value("t.txt") + private Resource testFile; + + @Value("http://www.baidu.com") + private Resource testUrl; + @Value("${sang.username}") + private String su; + @Value("${sang.password}") + private String sp; + @Value("${sang.nickname}") + private String sn; + @Autowired + private Environment environment; + + public void output() { + try { + System.out.println(normal); + System.out.println(osName); + System.out.println(osArch); + System.out.println(randomNumber); + System.out.println(author); + System.out.println(IOUtils.toString(testFile.getInputStream(),"UTF-8")); + //访问网址 + System.out.println(IOUtils.toString(testUrl.getInputStream(),"UTF-8")); + //获取网址 + System.out.println("testUrl.getURL():"+testUrl.getURL()); + System.out.println(su); + System.out.println(sp); + System.out.println(sn); + System.out.println(environment.getProperty("sang.nickname")); + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/Test8-EL/src/main/java/org/sang/Main.java b/Test8-EL/src/main/java/org/sang/Main.java new file mode 100644 index 00000000..8cb881b7 --- /dev/null +++ b/Test8-EL/src/main/java/org/sang/Main.java @@ -0,0 +1,15 @@ +package org.sang; + +import org.springframework.context.annotation.AnnotationConfigApplicationContext; + +/** + * Created by sang on 16-12-13. + */ +public class Main { + public static void main(String[] args) { + AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(MyConfig.class); + ELConfig bean = context.getBean(ELConfig.class); + bean.output(); + context.close(); + } +} diff --git a/Test8-EL/src/main/java/org/sang/MyConfig.java b/Test8-EL/src/main/java/org/sang/MyConfig.java new file mode 100644 index 00000000..390236c5 --- /dev/null +++ b/Test8-EL/src/main/java/org/sang/MyConfig.java @@ -0,0 +1,12 @@ +package org.sang; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +/** + * Created by sang on 16-12-13. + */ +@Configuration +@ComponentScan("org.sang") +public class MyConfig { +} diff --git a/Test8-EL/src/main/resources/t.properties b/Test8-EL/src/main/resources/t.properties new file mode 100644 index 00000000..c33927cf --- /dev/null +++ b/Test8-EL/src/main/resources/t.properties @@ -0,0 +1,3 @@ +sang.username=zhangsan +sang.password=123456 +sang.nickname=张三 \ No newline at end of file diff --git a/Test8-EL/src/main/resources/t.txt b/Test8-EL/src/main/resources/t.txt new file mode 100644 index 00000000..0e3a66ba --- /dev/null +++ b/Test8-EL/src/main/resources/t.txt @@ -0,0 +1,6 @@ +山居秋暝 +王维 +空山新雨后,天气晚来秋。 +明月松间照,清泉石上流。 +竹喧归浣女,莲动下渔舟。 +随意春芳歇,王孙自可留。 \ No newline at end of file diff --git a/Test8-EL/target/classes/org/sang/DemoService1.class b/Test8-EL/target/classes/org/sang/DemoService1.class new file mode 100644 index 00000000..d1e30ef8 Binary files /dev/null and b/Test8-EL/target/classes/org/sang/DemoService1.class differ diff --git a/Test8-EL/target/classes/org/sang/ELConfig.class b/Test8-EL/target/classes/org/sang/ELConfig.class new file mode 100644 index 00000000..82c98a08 Binary files /dev/null and b/Test8-EL/target/classes/org/sang/ELConfig.class differ diff --git a/Test8-EL/target/classes/org/sang/Main.class b/Test8-EL/target/classes/org/sang/Main.class new file mode 100644 index 00000000..00926f95 Binary files /dev/null and b/Test8-EL/target/classes/org/sang/Main.class differ diff --git a/Test8-EL/target/classes/org/sang/MyConfig.class b/Test8-EL/target/classes/org/sang/MyConfig.class new file mode 100644 index 00000000..d975dec5 Binary files /dev/null and b/Test8-EL/target/classes/org/sang/MyConfig.class differ diff --git a/Test8-EL/target/classes/t.properties b/Test8-EL/target/classes/t.properties new file mode 100644 index 00000000..c33927cf --- /dev/null +++ b/Test8-EL/target/classes/t.properties @@ -0,0 +1,3 @@ +sang.username=zhangsan +sang.password=123456 +sang.nickname=张三 \ No newline at end of file diff --git a/Test8-EL/target/classes/t.txt b/Test8-EL/target/classes/t.txt new file mode 100644 index 00000000..0e3a66ba --- /dev/null +++ b/Test8-EL/target/classes/t.txt @@ -0,0 +1,6 @@ +山居秋暝 +王维 +空山新雨后,天气晚来秋。 +明月松间照,清泉石上流。 +竹喧归浣女,莲动下渔舟。 +随意春芳歇,王孙自可留。 \ No newline at end of file