浏览代码

move to childProject

xiaoyuzhang 2 年之前
父节点
当前提交
2826b75cca

+ 4 - 0
pom.xml

@@ -6,7 +6,11 @@
6
 
6
 
7
     <groupId>org.example</groupId>
7
     <groupId>org.example</groupId>
8
     <artifactId>spring_demo</artifactId>
8
     <artifactId>spring_demo</artifactId>
9
+    <packaging>pom</packaging>
9
     <version>1.0-SNAPSHOT</version>
10
     <version>1.0-SNAPSHOT</version>
11
+    <modules>
12
+        <module>spring_annotation</module>
13
+    </modules>
10
 
14
 
11
     <properties>
15
     <properties>
12
         <maven.compiler.source>8</maven.compiler.source>
16
         <maven.compiler.source>8</maven.compiler.source>

+ 43 - 0
spring_annotation/pom.xml

@@ -0,0 +1,43 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project xmlns="http://maven.apache.org/POM/4.0.0"
3
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5
+    <parent>
6
+        <artifactId>spring_demo</artifactId>
7
+        <groupId>org.example</groupId>
8
+        <version>1.0-SNAPSHOT</version>
9
+    </parent>
10
+    <modelVersion>4.0.0</modelVersion>
11
+
12
+    <artifactId>spring_annotation</artifactId>
13
+
14
+    <properties>
15
+        <maven.compiler.source>8</maven.compiler.source>
16
+        <maven.compiler.target>8</maven.compiler.target>
17
+    </properties>
18
+    <build>
19
+        <finalName>Main</finalName>
20
+        <plugins>
21
+            <plugin>
22
+                <groupId>org.apache.maven.plugins</groupId>
23
+                <artifactId>maven-shade-plugin</artifactId>
24
+                <version>1.2.1</version>
25
+                <executions>
26
+                    <execution>
27
+                        <phase>package</phase>
28
+                        <goals>
29
+                            <goal>shade</goal>
30
+                        </goals>
31
+                        <configuration>
32
+                            <transformers>
33
+                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
34
+                                    <mainClass>Main</mainClass>
35
+                                </transformer>
36
+                            </transformers>
37
+                        </configuration>
38
+                    </execution>
39
+                </executions>
40
+            </plugin>
41
+        </plugins>
42
+    </build>
43
+</project>

+ 4 - 7
src/main/java/Main.java

@@ -8,9 +8,7 @@ import com.service.impl.MqServiceImpl;
8
 import com.service.impl.UserServiceImpl;
8
 import com.service.impl.UserServiceImpl;
9
 import org.springframework.beans.factory.BeanFactory;
9
 import org.springframework.beans.factory.BeanFactory;
10
 import org.springframework.context.ApplicationContext;
10
 import org.springframework.context.ApplicationContext;
11
-import org.springframework.context.annotation.ComponentScan;
12
 import org.springframework.context.support.ClassPathXmlApplicationContext;
11
 import org.springframework.context.support.ClassPathXmlApplicationContext;
13
-import org.springframework.context.support.FileSystemXmlApplicationContext;
14
 
12
 
15
 public class Main {
13
 public class Main {
16
     public static void main(String[] args) throws Exception {
14
     public static void main(String[] args) throws Exception {
@@ -21,14 +19,13 @@ public class Main {
21
         UserService bean = applicationContext.getBean(UserServiceImpl.class);
19
         UserService bean = applicationContext.getBean(UserServiceImpl.class);
22
 //        DruidDataSource dataSource = (DruidDataSource) beanFactory.getBean("dataSource");
20
 //        DruidDataSource dataSource = (DruidDataSource) beanFactory.getBean("dataSource");
23
         DruidDataSource dataSource = beanFactory.getBean(DruidDataSource.class);
21
         DruidDataSource dataSource = beanFactory.getBean(DruidDataSource.class);
24
- //       JdbcData bean1 = beanFactory.getBean(JdbcData.class);
22
+        //       JdbcData bean1 = beanFactory.getBean(JdbcData.class);
25
         DruidPooledConnection connection = dataSource.getConnection();
23
         DruidPooledConnection connection = dataSource.getConnection();
26
         connection.close();
24
         connection.close();
27
         // userService1 在 xml文件中定义
25
         // userService1 在 xml文件中定义
28
-       // MqService mqService =(MqService) applicationContext.getBean(MqServiceImpl.class);
29
-//        mqService.pushRabbitMessage();
30
-//        Thread.sleep(2000);
31
-//        mqService.listenRabbitQueue();
26
+         MqService mqService = applicationContext.getBean(MqServiceImpl.class);
27
+         mqService.pushRabbitMessage();
28
+//         mqService.listenRabbitQueue();
32
     }
29
     }
33
 
30
 
34
 }
31
 }

src/main/java/com/Config/JdbcData.java → spring_annotation/src/main/java/com/Config/JdbcData.java


src/main/java/com/controller/UserController.java → spring_annotation/src/main/java/com/controller/UserController.java


src/main/java/com/dao/StudentDao.java → spring_annotation/src/main/java/com/dao/StudentDao.java


src/main/java/com/dao/imp/StudentDaoImpl.java → spring_annotation/src/main/java/com/dao/imp/StudentDaoImpl.java


src/main/java/com/service/MqService.java → spring_annotation/src/main/java/com/service/MqService.java


src/main/java/com/service/StudentService.java → spring_annotation/src/main/java/com/service/StudentService.java


src/main/java/com/service/UserService.java → spring_annotation/src/main/java/com/service/UserService.java


+ 0 - 3
src/main/java/com/service/impl/StudentServiceImpl.java

@@ -3,11 +3,8 @@ package com.service.impl;
3
 import com.dao.StudentDao;
3
 import com.dao.StudentDao;
4
 import com.service.StudentService;
4
 import com.service.StudentService;
5
 import org.springframework.beans.factory.annotation.Autowired;
5
 import org.springframework.beans.factory.annotation.Autowired;
6
-import org.springframework.beans.factory.annotation.Qualifier;
7
 import org.springframework.stereotype.Service;
6
 import org.springframework.stereotype.Service;
8
 
7
 
9
-import javax.annotation.Resource;
10
-
11
 //<bean id="studentService" class="com.service.impl.StudentServiceImpl">
8
 //<bean id="studentService" class="com.service.impl.StudentServiceImpl">
12
 @Service
9
 @Service
13
 public class StudentServiceImpl implements StudentService {
10
 public class StudentServiceImpl implements StudentService {

+ 1 - 0
src/main/java/com/service/impl/UserServiceImpl.java

@@ -2,6 +2,7 @@ package com.service.impl;
2
 
2
 
3
 import com.service.UserService;
3
 import com.service.UserService;
4
 import org.springframework.stereotype.Service;
4
 import org.springframework.stereotype.Service;
5
+
5
 @Service("UserServiceImpl")
6
 @Service("UserServiceImpl")
6
 public class UserServiceImpl implements UserService {
7
 public class UserServiceImpl implements UserService {
7
 
8
 

src/main/resources/context.xml → spring_annotation/src/main/resources/context.xml


src/main/resources/jdbc.properties → spring_annotation/src/main/resources/jdbc.properties


+ 0 - 1
src/test/java/CommonTest1.java

@@ -1,7 +1,6 @@
1
 import com.Config.JdbcData;
1
 import com.Config.JdbcData;
2
 import org.junit.Test;
2
 import org.junit.Test;
3
 import org.springframework.beans.factory.annotation.Autowired;
3
 import org.springframework.beans.factory.annotation.Autowired;
4
-import org.springframework.beans.factory.annotation.Value;
5
 
4
 
6
 public class CommonTest1 {
5
 public class CommonTest1 {
7
     @Autowired
6
     @Autowired

+ 0 - 2
src/test/java/DataSourceTest.java

@@ -1,8 +1,6 @@
1
 import com.alibaba.druid.pool.DruidDataSource;
1
 import com.alibaba.druid.pool.DruidDataSource;
2
-import com.alibaba.druid.pool.DruidPooledConnection;
3
 import com.mchange.v2.c3p0.ComboPooledDataSource;
2
 import com.mchange.v2.c3p0.ComboPooledDataSource;
4
 import org.junit.Test;
3
 import org.junit.Test;
5
-import org.springframework.beans.factory.annotation.Value;
6
 
4
 
7
 import java.sql.Connection;
5
 import java.sql.Connection;
8
 import java.util.ResourceBundle;
6
 import java.util.ResourceBundle;

+ 0 - 12
src/main/java/StudentMain.java

@@ -1,12 +0,0 @@
1
-import com.service.StudentService;
2
-import com.service.impl.StudentServiceImpl;
3
-import org.springframework.context.ApplicationContext;
4
-import org.springframework.context.support.ClassPathXmlApplicationContext;
5
-
6
-public class StudentMain {
7
-    public static void main(String[] args) {
8
-        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("context.xml");
9
-        StudentService service = applicationContext.getBean(StudentServiceImpl.class);
10
-        service.showStudent();
11
-    }
12
-}