parent
85846516f1
commit
aedecc44d1
@ -1,13 +1,20 @@
|
||||
package cn.iocoder.mall.product;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
@SpringBootApplication
|
||||
@MapperScan("cn.iocoder.mall.product.dao") // 扫描对应的 Mapper 接口
|
||||
public class ProductRestApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ProductRestApplication.class, args);
|
||||
ConfigurableApplicationContext ctx = SpringApplication.run(ProductRestApplication.class, args);
|
||||
DataSource ds = ctx.getBean(DataSource.class);
|
||||
System.out.println(ds);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
package cn.iocoder.mall.product.dao;
|
||||
|
||||
import cn.iocoder.mall.product.dataobject.ProductSpuDO;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class ProductSpuDAO {
|
||||
|
||||
public ProductSpuDO selectById(Integer id) {
|
||||
ProductSpuDO spu = new ProductSpuDO();
|
||||
spu.setId(id);
|
||||
return spu;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package cn.iocoder.mall.product.dao;
|
||||
|
||||
import cn.iocoder.mall.product.dataobject.ProductSpuDO;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface ProductSpuMapper {
|
||||
|
||||
ProductSpuDO selectById(Integer id);
|
||||
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
spring:
|
||||
# datasource
|
||||
datasource:
|
||||
url: jdbc:mysql://127.0.0.1:33061/mall_product?useSSL=false
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
username: root
|
||||
password: 123456
|
||||
|
||||
# mybatis
|
||||
mybatis:
|
||||
config-location: classpath:mybatis/mybatis-config.xml
|
||||
mapper-locations: classpath:mybatis/mapper/*.xml
|
||||
type-aliases-package: cn.iocoder.mall.product.dataobject
|
||||
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.iocoder.mall.product.dao.ProductSpuMapper">
|
||||
|
||||
<select id="selectById" parameterType="Integer" resultType="ProductSpuDO">
|
||||
SELECT
|
||||
id
|
||||
FROM product_spu
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
|
||||
<configuration>
|
||||
|
||||
<settings>
|
||||
<!-- 使用驼峰命名法转换字段。 -->
|
||||
<setting name="mapUnderscoreToCamelCase" value="true"/>
|
||||
</settings>
|
||||
|
||||
<typeAliases>
|
||||
<typeAlias alias="Integer" type="java.lang.Integer"/>
|
||||
<typeAlias alias="Long" type="java.lang.Long"/>
|
||||
<typeAlias alias="HashMap" type="java.util.HashMap"/>
|
||||
<typeAlias alias="LinkedHashMap" type="java.util.LinkedHashMap"/>
|
||||
<typeAlias alias="ArrayList" type="java.util.ArrayList"/>
|
||||
<typeAlias alias="LinkedList" type="java.util.LinkedList"/>
|
||||
</typeAliases>
|
||||
|
||||
</configuration>
|
||||
Loading…
Reference in new issue