This commit is contained in:
parent
cf04d44196
commit
f1ba0bcab2
|
|
@ -26,11 +26,11 @@
|
||||||
<artifactId>spring-boot-starter-security</artifactId>
|
<artifactId>spring-boot-starter-security</artifactId>
|
||||||
<version>${spring-boot.version}</version>
|
<version>${spring-boot.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<!-- <dependency>-->
|
||||||
<groupId>com.baomidou</groupId>
|
<!-- <groupId>com.baomidou</groupId>-->
|
||||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
<!-- <artifactId>mybatis-plus-boot-starter</artifactId>-->
|
||||||
<version>3.5.5</version>
|
<!-- <version>3.5.5</version>-->
|
||||||
</dependency>
|
<!-- </dependency>-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||||
|
|
|
||||||
|
|
@ -93,11 +93,36 @@
|
||||||
<!-- <artifactId>druid-spring-boot-starter</artifactId>-->
|
<!-- <artifactId>druid-spring-boot-starter</artifactId>-->
|
||||||
<!-- <version>1.2.21</version>-->
|
<!-- <version>1.2.21</version>-->
|
||||||
<!-- </dependency>-->
|
<!-- </dependency>-->
|
||||||
|
<!-- <!– https://mvnrepository.com/artifact/com.baomidou/mybatis-plus-spring-boot3-starter –>-->
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>com.baomidou</groupId>-->
|
||||||
|
<!-- <artifactId>mybatis-plus-spring-boot3-starter</artifactId>-->
|
||||||
|
<!-- <version>3.5.5</version>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>com.baomidou</groupId>-->
|
||||||
|
<!-- <artifactId>mybatis-plus-boot-starter</artifactId>-->
|
||||||
|
<!-- <version>3.5.3</version>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
<!-- https://mvnrepository.com/artifact/com.baomidou/mybatis-plus-spring-boot3-starter -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baomidou</groupId>
|
<groupId>com.baomidou</groupId>
|
||||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||||
<version>3.5.5</version>
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.mybatis</groupId>
|
||||||
|
<artifactId>mybatis-spring</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
<version>3.5.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.mybatis/mybatis-spring -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mybatis</groupId>
|
||||||
|
<artifactId>mybatis-spring</artifactId>
|
||||||
|
<version>3.0.3</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-lang3</artifactId>
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,10 @@ import org.springframework.context.annotation.ComponentScan;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
//@EnableWebSecurity
|
//@EnableWebSecurity
|
||||||
@MapperScan("com.qihang.tao.mapper")
|
|
||||||
@EnableDiscoveryClient
|
@EnableDiscoveryClient
|
||||||
@ComponentScan(basePackages={"com.qihang"})
|
@ComponentScan(basePackages={"com.qihang"})
|
||||||
|
@MapperScan("com.qihang.tao.mapper")
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class TaoApi
|
public class TaoApi
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,25 @@
|
||||||
package com.qihang.tao.config;
|
//package com.qihang.tao.config;
|
||||||
|
//
|
||||||
import com.zaxxer.hikari.HikariDataSource;
|
//import com.zaxxer.hikari.HikariDataSource;
|
||||||
|
//
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Bean;
|
//import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
//import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.core.env.Environment;
|
//import org.springframework.core.env.Environment;
|
||||||
|
//
|
||||||
import javax.sql.DataSource;
|
//import javax.sql.DataSource;
|
||||||
@Configuration
|
//@Configuration
|
||||||
public class DataSourceConfig {
|
//public class DataSourceConfig {
|
||||||
@Autowired
|
// @Autowired
|
||||||
private Environment env;
|
// private Environment env;
|
||||||
|
//
|
||||||
@Bean
|
// @Bean
|
||||||
public DataSource dataSource() {
|
// public DataSource dataSource() {
|
||||||
HikariDataSource dataSource = new HikariDataSource();
|
// HikariDataSource dataSource = new HikariDataSource();
|
||||||
dataSource.setDriverClassName(env.getProperty("spring.datasource.driver-class-name"));
|
// dataSource.setDriverClassName(env.getProperty("spring.datasource.driver-class-name"));
|
||||||
dataSource.setJdbcUrl(env.getProperty("spring.datasource.url"));
|
// dataSource.setJdbcUrl(env.getProperty("spring.datasource.url"));
|
||||||
dataSource.setUsername(env.getProperty("spring.datasource.username"));
|
// dataSource.setUsername(env.getProperty("spring.datasource.username"));
|
||||||
dataSource.setPassword(env.getProperty("spring.datasource.password"));
|
// dataSource.setPassword(env.getProperty("spring.datasource.password"));
|
||||||
return dataSource;
|
// return dataSource;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
||||||
|
|
@ -1,33 +1,33 @@
|
||||||
package com.qihang.tao.config;
|
//package com.qihang.tao.config;
|
||||||
|
//
|
||||||
import org.apache.ibatis.session.SqlSessionFactory;
|
//import org.apache.ibatis.session.SqlSessionFactory;
|
||||||
import org.mybatis.spring.SqlSessionFactoryBean;
|
//import org.mybatis.spring.SqlSessionFactoryBean;
|
||||||
import org.mybatis.spring.SqlSessionTemplate;
|
//import org.mybatis.spring.SqlSessionTemplate;
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
//import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Bean;
|
//import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
//import org.springframework.context.annotation.Configuration;
|
||||||
|
//
|
||||||
import javax.sql.DataSource;
|
//import javax.sql.DataSource;
|
||||||
|
//
|
||||||
@Configuration
|
//@Configuration
|
||||||
@MapperScan("com.qihang.tao.mapper")
|
//@MapperScan("com.qihang.tao.mapper")
|
||||||
public class MyBatisConfig {
|
//public class MyBatisConfig {
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private DataSource dataSource;
|
// private DataSource dataSource;
|
||||||
|
//
|
||||||
@Bean
|
// @Bean
|
||||||
public SqlSessionFactory sqlSessionFactory() throws Exception {
|
// public SqlSessionFactory sqlSessionFactory() throws Exception {
|
||||||
SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
|
// SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean();
|
||||||
factoryBean.setDataSource(dataSource);
|
// factoryBean.setDataSource(dataSource);
|
||||||
return factoryBean.getObject();
|
// return factoryBean.getObject();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Bean
|
// @Bean
|
||||||
public SqlSessionTemplate sqlSessionTemplate(SqlSessionFactory sqlSessionFactory) {
|
// public SqlSessionTemplate sqlSessionTemplate(SqlSessionFactory sqlSessionFactory) {
|
||||||
return new SqlSessionTemplate(sqlSessionFactory);
|
// return new SqlSessionTemplate(sqlSessionFactory);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,83 @@
|
||||||
|
//package com.qihang.tao.config;
|
||||||
|
//
|
||||||
|
//import com.baomidou.mybatisplus.autoconfigure.SpringBootVFS;
|
||||||
|
//import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
|
||||||
|
//import org.apache.ibatis.session.SqlSessionFactory;
|
||||||
|
//import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
|
//import org.springframework.context.annotation.Bean;
|
||||||
|
//import org.springframework.util.ObjectUtils;
|
||||||
|
//import org.springframework.util.StringUtils;
|
||||||
|
//
|
||||||
|
//import javax.sql.DataSource;
|
||||||
|
//
|
||||||
|
//public class MybatisPlusAutoConfiguration {
|
||||||
|
// @Bean
|
||||||
|
// @ConditionalOnMissingBean //spring容器中不存在SqlSessionFactory的bean对象才会运行该方法
|
||||||
|
// public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception {
|
||||||
|
// MybatisSqlSessionFactoryBean factory = new MybatisSqlSessionFactoryBean();
|
||||||
|
// factory.setDataSource(dataSource);
|
||||||
|
// factory.setVfs(SpringBootVFS.class);
|
||||||
|
// if (StringUtils.hasText(this.properties.getConfigLocation())) {
|
||||||
|
// factory.setConfigLocation(this.resourceLoader.getResource(this.properties.getConfigLocation()));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// this.applyConfiguration(factory);
|
||||||
|
// if (this.properties.getConfigurationProperties() != null) {
|
||||||
|
// factory.setConfigurationProperties(this.properties.getConfigurationProperties());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (!ObjectUtils.isEmpty(this.interceptors)) {
|
||||||
|
// factory.setPlugins(this.interceptors);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (this.databaseIdProvider != null) {
|
||||||
|
// factory.setDatabaseIdProvider(this.databaseIdProvider);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (StringUtils.hasLength(this.properties.getTypeAliasesPackage())) {
|
||||||
|
// factory.setTypeAliasesPackage(this.properties.getTypeAliasesPackage());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (this.properties.getTypeAliasesSuperType() != null) {
|
||||||
|
// factory.setTypeAliasesSuperType(this.properties.getTypeAliasesSuperType());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (StringUtils.hasLength(this.properties.getTypeHandlersPackage())) {
|
||||||
|
// factory.setTypeHandlersPackage(this.properties.getTypeHandlersPackage());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (!ObjectUtils.isEmpty(this.typeHandlers)) {
|
||||||
|
// factory.setTypeHandlers(this.typeHandlers);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //是否配置了MapperLocations路径
|
||||||
|
// if (!ObjectUtils.isEmpty(this.properties.resolveMapperLocations())) {
|
||||||
|
// factory.setMapperLocations(this.properties.resolveMapperLocations());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Objects.requireNonNull(factory);
|
||||||
|
// this.getBeanThen(TransactionFactory.class, factory::setTransactionFactory);
|
||||||
|
// Class<? extends LanguageDriver> defaultLanguageDriver = this.properties.getDefaultScriptingLanguageDriver();
|
||||||
|
// if (!ObjectUtils.isEmpty(this.languageDrivers)) {
|
||||||
|
// factory.setScriptingLanguageDrivers(this.languageDrivers);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Optional var10000 = Optional.ofNullable(defaultLanguageDriver);
|
||||||
|
// Objects.requireNonNull(factory);
|
||||||
|
// var10000.ifPresent(factory::setDefaultScriptingLanguageDriver);
|
||||||
|
// this.applySqlSessionFactoryBeanCustomizers(factory);
|
||||||
|
// GlobalConfig globalConfig = this.properties.getGlobalConfig();
|
||||||
|
// Objects.requireNonNull(globalConfig);
|
||||||
|
// this.getBeanThen(MetaObjectHandler.class, globalConfig::setMetaObjectHandler);
|
||||||
|
// this.getBeansThen(IKeyGenerator.class, (i) -> {
|
||||||
|
// globalConfig.getDbConfig().setKeyGenerators(i);
|
||||||
|
// });
|
||||||
|
// Objects.requireNonNull(globalConfig);
|
||||||
|
// this.getBeanThen(ISqlInjector.class, globalConfig::setSqlInjector);
|
||||||
|
// Objects.requireNonNull(globalConfig);
|
||||||
|
// this.getBeanThen(IdentifierGenerator.class, globalConfig::setIdentifierGenerator);
|
||||||
|
// factory.setGlobalConfig(globalConfig);
|
||||||
|
// return factory.getObject();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package com.qihang.tao.controller;
|
package com.qihang.tao.controller;
|
||||||
|
|
||||||
|
import com.qihang.tao.domain.TaoGoods;
|
||||||
|
import com.qihang.tao.mapper.TaoGoodsMapper;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
|
@ -9,6 +11,8 @@ import org.springframework.web.bind.annotation.RestController;
|
||||||
@RestController
|
@RestController
|
||||||
public class
|
public class
|
||||||
HomeController {
|
HomeController {
|
||||||
|
@Autowired
|
||||||
|
private TaoGoodsMapper goodsMapper;
|
||||||
@GetMapping("/")
|
@GetMapping("/")
|
||||||
public String home(){
|
public String home(){
|
||||||
return "{'code':0,'msg':'请通过api访问'}";
|
return "{'code':0,'msg':'请通过api访问'}";
|
||||||
|
|
@ -21,6 +25,9 @@ HomeController {
|
||||||
public String get(HttpServletRequest request) {
|
public String get(HttpServletRequest request) {
|
||||||
String token = request.getHeader("Authorization");
|
String token = request.getHeader("Authorization");
|
||||||
System.out.println("tao-api token:"+token);
|
System.out.println("tao-api token:"+token);
|
||||||
|
|
||||||
|
TaoGoods taoGoods = goodsMapper.selectById(1L);
|
||||||
|
|
||||||
return serverName;
|
return serverName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@ package com.qihang.tao.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.qihang.tao.domain.TaoGoods;
|
import com.qihang.tao.domain.TaoGoods;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
public interface TaoGoodsMapper extends BaseMapper<TaoGoods> {
|
public interface TaoGoodsMapper extends BaseMapper<TaoGoods> {
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,6 @@ server:
|
||||||
|
|
||||||
mybatis-plus:
|
mybatis-plus:
|
||||||
mapper-locations: classpath*:mapper/**/*Mapper.xml
|
mapper-locations: classpath*:mapper/**/*Mapper.xml
|
||||||
type-aliases-package: com.qihang.tao.domain;com.qihang.tao.mapper
|
type-aliases-package: com.qihang.tao.domain;com.qihang.security.entity;
|
||||||
configuration:
|
configuration:
|
||||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 开启sql日志
|
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 开启sql日志
|
||||||
Loading…
Reference in New Issue