package com.hcx.springboot.javaconfig;
public class User {
private String username;
private String password;
private Integer age;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
}
(3)编写userdao用于模拟与数据库的交互
package com.hcx.springboot.javaconfig;
import java.util.ArrayList;
import java.util.List;
public class UserDao {
public List queryUserList(){
List result = new ArrayList();
//模拟数据库的查询
for(int i = 0;i<10;i++){
User user = new User();
user.setUsername("username_"+i);
user.setPassword("password_"+i);
user.setAge(i+1);
result.add(user);
}
return result;
}
}
(4)编写UserService用于实现User数据操作业务逻辑
package com.hcx.springboot.javaconfig;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class UserService {
@Autowired
private UserDao userDao;
public List queryUserList(){
return this.userDao.queryUserList();
}
}
(5)编写SpringConfig 用于实例化Spring容器
package com.hcx.springboot.javaconfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration//通过注解来表明该类是一个Spring的配置,相当于一个xml文件
@ComponentScan(basePackages="com.hcx.springboot.javaconfig")//配置扫描包
public class SpringConfig {
@Bean //通过该注解来表明是一个bean对象,相当于xml中的
public UserDao getUserDao(){
return new UserDao();
}
}
(6)编写测试方法用于启动spring容器
package com.hcx.springboot.javaconfig;
import java.util.List;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
public class Main {
public static void main(String[] args) {
//通过java配置来实例化spring容器
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig.class);
//在spring容器中获取bean对象 (因为在context中已经扫描了com.hcx.springboot.javaconfig包)
UserService userService = context.getBean(UserService.class);
//调用对象中的方法
List list = userService.queryUserList();
for (User user : list) {
System.out.println(user.getUsername() + ","+user.getPassword()+","+user.getPassword());
}
//销毁容器
context.destroy();
}
}
例如,你想myuser使用mypassword从任何主机连接到mysql服务器的话。
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%'IDENTIFIED BY 'mypassword' WI
TH GRANT OPTION;
如果你想允许用户myuser从ip为192.168.1.6的主机连接到mysql服务器,并使用mypassword作
在 Service Pack 4 (SP 4), 是运行 Microsoft Windows Server 2003、 Microsoft Windows Storage Server 2003 或 Microsoft Windows 2000 服务器上您尝试安装 Microsoft SQL Server 2000 通过卷许可协议 (VLA) 媒体。 这样做, 收到以下错误信息CD KEY的 SQ
OS 7 has a new method that allows you to draw a view hierarchy into the current graphics context. This can be used to get an UIImage very fast.
I implemented a category method on UIView to get the vi
方法一:
在my.ini的[mysqld]字段加入:
skip-grant-tables
重启mysql服务,这时的mysql不需要密码即可登录数据库
然后进入mysql
mysql>use mysql;
mysql>更新 user set password=password('新密码') WHERE User='root';
mysq
背景
2014年11月12日,ASP.NET之父、微软云计算与企业级产品工程部执行副总裁Scott Guthrie,在Connect全球开发者在线会议上宣布,微软将开源全部.NET核心运行时,并将.NET 扩展为可在 Linux 和 Mac OS 平台上运行。.NET核心运行时将基于MIT开源许可协议发布,其中将包括执行.NET代码所需的一切项目——CLR、JIT编译器、垃圾收集器(GC)和核心