目录
ssm_dao子项目:
User实体类在ssm_pojo子项目中,如何导入User类呢?
在ssm_dao子项目中导入ssm_pojo的项目ID
- <dependency>
- <groupId>com.feng</groupId>
- <artifactId>ssm_pojo</artifactId>
- <version>1.0-SNAPSHOT</version>
- </dependency>
重新编译一下:
compile之后,编译报错:
之所以引入ssm_pojo的Id后还会报错,是因为本地maven仓库中,没有拉取ssm)_pojo的项目依赖
解决办法:在ssm_pojo的maven窗口之中, install一下
现在看本地仓库下面:
现在可以在ssm_dao子项目中重新compile一下,就不会报错了
ssm_dao项目中的pom.xml 配置如下:
- <?xml version="1.0" encoding="UTF-8"?>
- <project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>com.feng</groupId>
- <artifactId>ssm_dao</artifactId>
- <version>1.0-SNAPSHOT</version>
-
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <maven.compiler.source>1.8</maven.compiler.source>
- <maven.compiler.target>1.8</maven.compiler.target>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- <version>5.1.9.RELEASE</version>
- </dependency>
-
- <dependency>
- <groupId>org.mybatis</groupId>
- <artifactId>mybatis</artifactId>
- <version>3.5.3</version>
- </dependency>
- <dependency>
- <groupId>org.mybatis</groupId>
- <artifactId>mybatis-spring</artifactId>
- <version>2.0.7</version>
- </dependency>
- <dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <version>5.1.47</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-jdbc</artifactId>
- <version>5.1.9.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>com.alibaba</groupId>
- <artifactId>druid</artifactId>
- <version>1.1.16</version>
- </dependency>
- <dependency>
- <groupId>com.github.pagehelper</groupId>
- <artifactId>pagehelper</artifactId>
- <version>5.1.2</version>
- </dependency>
- <dependency>
- <groupId>com.feng</groupId>
- <artifactId>ssm_pojo</artifactId>
- <version>1.0-SNAPSHOT</version>
- </dependency>
-
-
- </dependencies>
-
-
-
- </project>
ssm_dao项目中的applicationContext.xml中的配置
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/aop
- http://www.springframework.org/schema/aop/spring-aop.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context.xsd">
-
- <!--开启bean注解扫描-->
- <context:component-scan base-package="com.feng" />
-
- <!--开启注解式事务-->
- <tx:annotation-driven transaction-manager="txManager" />
- <!--加载properties文件-->
- <context:property-placeholder location="classpath*:jdbc.properties" />
-
- <!--数据源-->
- <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
- <property name="driverClassName" value="${jdbc.driver}" />
- <property name="url" value="${jdbc.url}" />
- <property name="username" value="${jdbc.username}" />
- <property name="password" value="${jdbc.password}" />
- </bean>
-
- <!--整合mybatis到spring中-->
- <bean class="org.mybatis.spring.SqlSessionFactoryBean">
- <property name="dataSource" ref="dataSource" />
- <property name="typeAliasesPackage" value="com.feng.pojo" />
- <!--分页插件-->
- <property name="plugins">
- <array>
- <bean class="com.github.pagehelper.PageInterceptor">
- <property name="properties">
- <props>
- <prop key="helperDialect">mysql</prop>
- <prop key="reasonable">true</prop>
- </props>
- </property>
- </bean>
- </array>
- </property>
- </bean>
-
- <!--映射扫描-->
- <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
- <property name="basePackage" value="com.feng.dao" />
- </bean>
-
- <!--事务管理-->
- <bean name="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
- <property name="dataSource" ref="dataSource" />
- </bean>
-
- </beans>
新建一个模块ssm, 里面没有任何东西,只有一个pom.xml
解决快速构建的问题
ssm模块,里面没有任何东西,只有一个pom.xml, 如下所示:
- <?xml version="1.0" encoding="UTF-8"?>
- <project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>com.feng</groupId>
- <artifactId>ssm</artifactId>
- <version>1.0-SNAPSHOT</version>
-
- <!--定义该工程用于进行构建管理-->
- <packaging>pom</packaging>
-
- <!--管理的工程列表-->
- <modules>
- <!--具体的工程名称-->
- <module>../ssm_pojo</module>
- <module>../ssm_dao</module>
- <module>../ssm_service</module>
- <module>../ssm_controller</module>
- </modules>
-
-
- </project>
新建一个模块ssm,作为父工程, 里面没有任何东西,只有一个pom.xml
解决下面依赖不兼容的问题
例如: jdbc.properties里面的内容也可以配置在pom.xml中
需要在父工程的pom.xml配置 resources
或
配置测试资源文件对应的信息
跳过测试环节的应用场景
Nexus
下载好后,解压:
启动服务器:
具体操作: