0.结构

一、JDBC层

1.

 package spittr.db;

 import java.util.List;

 import spittr.domain.Spitter;

 /**
* Repository interface with operations for {@link Spitter} persistence.
* @author habuma
*/
public interface SpitterRepository { long count(); Spitter save(Spitter spitter); Spitter findOne(long id); Spitter findByUsername(String username); List<Spitter> findAll(); }

2.

 package spittr.db;

 import java.util.List;

 import spittr.domain.Spittle;

 /**
* Repository interface with operations for {@link Spittle} persistence.
* @author habuma
*/
public interface SpittleRepository { long count(); List<Spittle> findRecent(); List<Spittle> findRecent(int count); Spittle findOne(long id); Spittle save(Spittle spittle); List<Spittle> findBySpitterId(long spitterId); void delete(long id); }

3.

 package spittr.db.jdbc;

 import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.simple.SimpleJdbcInsert; import spittr.db.SpitterRepository;
import spittr.domain.Spitter; public class JdbcSpitterRepository implements SpitterRepository { private JdbcTemplate jdbcTemplate; public JdbcSpitterRepository(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
} public long count() {
//return jdbcTemplate.queryForLong("select count(id) from Spitter");
return jdbcTemplate.queryForObject("select count(id) from Spitter", Long.class);
} public Spitter save(Spitter spitter) {
Long id = spitter.getId();
if (id == null) {
long spitterId = insertSpitterAndReturnId(spitter);
return new Spitter(spitterId, spitter.getUsername(), spitter.getPassword(), spitter.getFullName(), spitter.getEmail(), spitter.isUpdateByEmail());
} else {
jdbcTemplate.update("update Spitter set username=?, password=?, fullname=?, email=?, updateByEmail=? where id=?",
spitter.getUsername(),
spitter.getPassword(),
spitter.getFullName(),
spitter.getEmail(),
spitter.isUpdateByEmail(),
id);
}
return spitter;
} /**
* Inserts a spitter using SimpleJdbcInsert.
* Involves no direct SQL and is able to return the ID of the newly created Spitter.
* @param spitter a Spitter to insert into the databse
* @return the ID of the newly inserted Spitter
*/
private long insertSpitterAndReturnId(Spitter spitter) {
SimpleJdbcInsert jdbcInsert = new SimpleJdbcInsert(jdbcTemplate).withTableName("Spitter");
jdbcInsert.setGeneratedKeyName("id");
Map<String, Object> args = new HashMap<String, Object>();
args.put("username", spitter.getUsername());
args.put("password", spitter.getPassword());
args.put("fullname", spitter.getFullName());
args.put("email", spitter.getEmail());
args.put("updateByEmail", spitter.isUpdateByEmail());
long spitterId = jdbcInsert.executeAndReturnKey(args).longValue();
return spitterId;
} /**
* Inserts a spitter using a simple JdbcTemplate update() call.
* Does not return the ID of the newly created Spitter.
* @param spitter a Spitter to insert into the database
*/
@SuppressWarnings("unused")
private void insertSpitter(Spitter spitter) {
jdbcTemplate.update(INSERT_SPITTER,
spitter.getUsername(),
spitter.getPassword(),
spitter.getFullName(),
spitter.getEmail(),
spitter.isUpdateByEmail());
} public Spitter findOne(long id) {
return jdbcTemplate.queryForObject(
SELECT_SPITTER + " where id=?", new SpitterRowMapper(), id);
} public Spitter findByUsername(String username) {
return jdbcTemplate.queryForObject("select id, username, password, fullname, email, updateByEmail from Spitter where username=?", new SpitterRowMapper(), username);
} public List<Spitter> findAll() {
return jdbcTemplate.query("select id, username, password, fullname, email, updateByEmail from Spitter order by id", new SpitterRowMapper());
} private static final class SpitterRowMapper implements RowMapper<Spitter> {
public Spitter mapRow(ResultSet rs, int rowNum) throws SQLException {
long id = rs.getLong("id");
String username = rs.getString("username");
String password = rs.getString("password");
String fullName = rs.getString("fullname");
String email = rs.getString("email");
boolean updateByEmail = rs.getBoolean("updateByEmail");
return new Spitter(id, username, password, fullName, email, updateByEmail);
}
} private static final String INSERT_SPITTER = "insert into Spitter (username, password, fullname, email, updateByEmail) values (?, ?, ?, ?, ?)"; private static final String SELECT_SPITTER = "select id, username, password, fullname, email, updateByEmail from Spitter"; }

4.

 package spittr.db.jdbc;

 import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map; import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.simple.SimpleJdbcInsert; import spittr.db.SpittleRepository;
import spittr.domain.Spitter;
import spittr.domain.Spittle; public class JdbcSpittleRepository implements SpittleRepository { private static final String SELECT_SPITTLE = "select sp.id, s.id as spitterId, s.username, s.password, s.fullname, s.email, s.updateByEmail, sp.message, sp.postedTime from Spittle sp, Spitter s where sp.spitter = s.id";
private static final String SELECT_SPITTLE_BY_ID = SELECT_SPITTLE + " and sp.id=?";
private static final String SELECT_SPITTLES_BY_SPITTER_ID = SELECT_SPITTLE + " and s.id=? order by sp.postedTime desc";
private static final String SELECT_RECENT_SPITTLES = SELECT_SPITTLE + " order by sp.postedTime desc limit ?"; private JdbcTemplate jdbcTemplate; public JdbcSpittleRepository(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
} public long count() {
//return jdbcTemplate.queryForLong("select count(id) from Spittle");
return jdbcTemplate.queryForObject("select count(id) from Spittle", Long.class);
} public List<Spittle> findRecent() {
return findRecent(10);
} public List<Spittle> findRecent(int count) {
return jdbcTemplate.query(SELECT_RECENT_SPITTLES, new SpittleRowMapper(), count);
} public Spittle findOne(long id) {
try {
return jdbcTemplate.queryForObject(SELECT_SPITTLE_BY_ID, new SpittleRowMapper(), id);
} catch (EmptyResultDataAccessException e) {
return null;
}
} public List<Spittle> findBySpitterId(long spitterId) {
return jdbcTemplate.query(SELECT_SPITTLES_BY_SPITTER_ID, new SpittleRowMapper(), spitterId);
} public Spittle save(Spittle spittle) {
long spittleId = insertSpittleAndReturnId(spittle);
return new Spittle(spittleId, spittle.getSpitter(), spittle.getMessage(), spittle.getPostedTime());
} private long insertSpittleAndReturnId(Spittle spittle) {
SimpleJdbcInsert jdbcInsert = new SimpleJdbcInsert(jdbcTemplate).withTableName("Spittle");
jdbcInsert.setGeneratedKeyName("id");
Map<String, Object> args = new HashMap<String, Object>();
args.put("spitter", spittle.getSpitter().getId());
args.put("message", spittle.getMessage());
args.put("postedTime", spittle.getPostedTime());
long spittleId = jdbcInsert.executeAndReturnKey(args).longValue();
return spittleId;
} public void delete(long id) {
jdbcTemplate.update("delete from Spittle where id=?", id);
} private static final class SpittleRowMapper implements RowMapper<Spittle> {
public Spittle mapRow(ResultSet rs, int rowNum) throws SQLException {
long id = rs.getLong("id");
String message = rs.getString("message");
Date postedTime = rs.getTimestamp("postedTime");
long spitterId = rs.getLong("spitterId");
String username = rs.getString("username");
String password = rs.getString("password");
String fullName = rs.getString("fullname");
String email = rs.getString("email");
boolean updateByEmail = rs.getBoolean("updateByEmail");
Spitter spitter = new Spitter(spitterId, username, password, fullName, email, updateByEmail);
return new Spittle(id, spitter, message, postedTime);
}
} }

二、Domain层

1.

 package spittr.domain;

 public class Spitter {

   private Long id;
private String username;
private String password;
private String fullName;
private String email;
private boolean updateByEmail; public Spitter(Long id, String username, String password, String fullName, String email, boolean updateByEmail) {
this.id = id;
this.username = username;
this.password = password;
this.fullName = fullName;
this.email = email;
this.updateByEmail = updateByEmail;
} public Long getId() {
return id;
} public String getUsername() {
return username;
} public String getPassword() {
return password;
} public String getFullName() {
return fullName;
} public String getEmail() {
return email;
} public boolean isUpdateByEmail() {
return updateByEmail;
} }

2.

 package spittr.domain;

 import java.util.Date;

 public class Spittle {
private final Long id;
private final Spitter spitter;
private final String message;
private final Date postedTime; public Spittle(Long id, Spitter spitter, String message, Date postedTime) {
this.id = id;
this.spitter = spitter;
this.message = message;
this.postedTime = postedTime;
} public Long getId() {
return this.id;
} public String getMessage() {
return this.message;
} public Date getPostedTime() {
return this.postedTime;
} public Spitter getSpitter() {
return this.spitter;
} }

三、配置文件及数据库文件

1.JdbcConfig.java

 package spittr.jdbc;

 import javax.sql.DataSource;

 import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
import org.springframework.transaction.PlatformTransactionManager; import spittr.db.SpitterRepository;
import spittr.db.SpittleRepository;
import spittr.db.jdbc.JdbcSpitterRepository;
import spittr.db.jdbc.JdbcSpittleRepository; @Configuration
public class JdbcConfig { @Bean
public DataSource dataSource() {
return new EmbeddedDatabaseBuilder()
.setType(EmbeddedDatabaseType.H2)
.addScripts("classpath:spittr/db/jdbc/schema.sql", "classpath:spittr/db/jdbc/test-data.sql")
.build();
} @Bean
public JdbcTemplate jdbcTemplate(DataSource dataSource) {
return new JdbcTemplate(dataSource);
} @Bean
public SpitterRepository spitterRepository(JdbcTemplate jdbcTemplate) {
return new JdbcSpitterRepository(jdbcTemplate);
} @Bean
public SpittleRepository spittleRepository(JdbcTemplate jdbcTemplate) {
return new JdbcSpittleRepository(jdbcTemplate);
} @Bean
public PlatformTransactionManager transactionManager(DataSource dataSource) {
return new DataSourceTransactionManager(dataSource);
} }

2.或用xml配置(JdbcRepositoryTests-context.xml)

 <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:c="http://www.springframework.org/schema/c"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <jdbc:embedded-database id="dataSource" type="H2">
<jdbc:script location="classpath:spittr/db/jdbc/schema.sql" />
<jdbc:script location="classpath:spittr/db/jdbc/test-data.sql" />
</jdbc:embedded-database> <bean id="jdbcTemplate"
class="org.springframework.jdbc.core.JdbcTemplate"
c:_-ref="dataSource" /> <bean class="spittr.db.jdbc.JdbcSpitterRepository"
c:_-ref="jdbcTemplate" /> <bean class="spittr.db.jdbc.JdbcSpittleRepository"
c:_-ref="jdbcTemplate" /> <bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
c:_-ref="dataSource" /> </beans>

3.schema.sql

 drop table if exists spittle;
drop table if exists spitter; create table spitter (
id identity,
username varchar(25) not null,
password varchar(25) not null,
fullName varchar(100) not null,
email varchar(50) not null,
updateByEmail boolean not null
); create table spittle (
id integer identity primary key,
spitter integer not null,
message varchar(2000) not null,
postedTime datetime not null,
foreign key (spitter) references spitter(id)
);

4.test-data.sql

 insert into Spitter (username, password, fullname, email, updateByEmail) values ('habuma', 'password', 'Craig Walls', 'craig@habuma.com', false);
insert into Spitter (username, password, fullname, email, updateByEmail) values ('mwalls', 'password', 'Michael Walls', 'mwalls@habuma.com', true);
insert into Spitter (username, password, fullname, email, updateByEmail) values ('chuck', 'password', 'Chuck Wagon', 'chuck@habuma.com', false);
insert into Spitter (username, password, fullname, email, updateByEmail) values ('artnames', 'password', 'Art Names', 'art@habuma.com', true); insert into Spittle (spitter, message, postedTime) values (1, 'This is a test spittle message', '2012-06-09 22:00:00Z');
insert into Spittle (spitter, message, postedTime) values (1, 'This is another test spittle message', '2012-06-09 22:10:00Z');
insert into Spittle (spitter, message, postedTime) values (1, 'This is a third test spittle message', '2012-07-04 23:30:00Z');
insert into Spittle (spitter, message, postedTime) values (2, 'Hello from Chuck!', '2012-03-25 12:15:00Z');
insert into Spittle (spitter, message, postedTime) values (4, 'Hello from Art!', '2012-03-25 12:15:00Z');
insert into Spittle (spitter, message, postedTime) values (4, 'Hello again from Art!', '2012-03-25 12:25:00Z');
insert into Spittle (spitter, message, postedTime) values (4, 'Hola from Arthur!', '2012-03-25 12:35:00Z');
insert into Spittle (spitter, message, postedTime) values (4, 'Buenos Dias from Art!', '2012-03-25 12:45:00Z');
insert into Spittle (spitter, message, postedTime) values (4, 'Ni Hao from Art!', '2012-03-25 12:55:00Z');
insert into Spittle (spitter, message, postedTime) values (4, 'Guten Tag from Art!', '2012-03-25 13:05:00Z');
insert into Spittle (spitter, message, postedTime) values (4, 'Konnichi wa from Art!', '2012-03-25 13:15:00Z');
insert into Spittle (spitter, message, postedTime) values (4, 'Buon giorno from Art!', '2012-03-25 13:25:00Z');
insert into Spittle (spitter, message, postedTime) values (4, 'Bonjour from Art!', '2012-03-25 13:35:00Z');
insert into Spittle (spitter, message, postedTime) values (4, 'Aloha from Art!', '2012-03-25 13:45:00Z');
insert into Spittle (spitter, message, postedTime) values (4, 'God dag from Art!', '2012-03-25 13:55:00Z');

四、测试文件

1.

 package spittr.jdbc;

 import static org.junit.Assert.*;

 import java.util.List;

 import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional; import spittr.db.jdbc.JdbcSpitterRepository;
import spittr.domain.Spitter; @RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes=JdbcConfig.class)
public class JdbcSpitterRepositoryTest { @Autowired
JdbcSpitterRepository spitterRepository; @Test
public void count() {
assertEquals(4, spitterRepository.count());
} @Test
@Transactional
public void findAll() {
List<Spitter> spitters = spitterRepository.findAll();
assertEquals(4, spitters.size());
assertSpitter(0, spitters.get(0));
assertSpitter(1, spitters.get(1));
assertSpitter(2, spitters.get(2));
assertSpitter(3, spitters.get(3));
} @Test
@Transactional
public void findByUsername() {
assertSpitter(0, spitterRepository.findByUsername("habuma"));
assertSpitter(1, spitterRepository.findByUsername("mwalls"));
assertSpitter(2, spitterRepository.findByUsername("chuck"));
assertSpitter(3, spitterRepository.findByUsername("artnames"));
} @Test
@Transactional
public void findOne() {
assertSpitter(0, spitterRepository.findOne(1L));
assertSpitter(1, spitterRepository.findOne(2L));
assertSpitter(2, spitterRepository.findOne(3L));
assertSpitter(3, spitterRepository.findOne(4L));
} @Test
@Transactional
public void save_newSpitter() {
assertEquals(4, spitterRepository.count());
Spitter spitter = new Spitter(null, "newbee", "letmein", "New Bee",
"newbee@habuma.com", true);
Spitter saved = spitterRepository.save(spitter);
assertEquals(5, spitterRepository.count());
assertSpitter(4, saved);
assertSpitter(4, spitterRepository.findOne(5L));
} @Test
@Transactional
public void save_existingSpitter() {
assertEquals(4, spitterRepository.count());
Spitter spitter = new Spitter(4L, "arthur", "letmein", "Arthur Names",
"arthur@habuma.com", false);
Spitter saved = spitterRepository.save(spitter);
assertSpitter(5, saved);
assertEquals(4, spitterRepository.count());
Spitter updated = spitterRepository.findOne(4L);
assertSpitter(5, updated);
} private static void assertSpitter(int expectedSpitterIndex, Spitter actual) {
assertSpitter(expectedSpitterIndex, actual, "Newbie");
} private static void assertSpitter(int expectedSpitterIndex, Spitter actual,
String expectedStatus) {
Spitter expected = SPITTERS[expectedSpitterIndex];
assertEquals(expected.getId(), actual.getId());
assertEquals(expected.getUsername(), actual.getUsername());
assertEquals(expected.getPassword(), actual.getPassword());
assertEquals(expected.getFullName(), actual.getFullName());
assertEquals(expected.getEmail(), actual.getEmail());
assertEquals(expected.isUpdateByEmail(), actual.isUpdateByEmail());
} private static Spitter[] SPITTERS = new Spitter[6]; @BeforeClass
public static void before() {
SPITTERS[0] = new Spitter(1L, "habuma", "password", "Craig Walls",
"craig@habuma.com", false);
SPITTERS[1] = new Spitter(2L, "mwalls", "password", "Michael Walls",
"mwalls@habuma.com", true);
SPITTERS[2] = new Spitter(3L, "chuck", "password", "Chuck Wagon",
"chuck@habuma.com", false);
SPITTERS[3] = new Spitter(4L, "artnames", "password", "Art Names",
"art@habuma.com", true);
SPITTERS[4] = new Spitter(5L, "newbee", "letmein", "New Bee",
"newbee@habuma.com", true);
SPITTERS[5] = new Spitter(4L, "arthur", "letmein", "Arthur Names",
"arthur@habuma.com", false);
} }

2.

 package spittr.jdbc;

 import static org.junit.Assert.*;

 import java.util.Date;
import java.util.List; import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional; import spittr.db.jdbc.JdbcSpittleRepository;
import spittr.domain.Spitter;
import spittr.domain.Spittle; @RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes=JdbcConfig.class)
public class JdbcSpittleRepositoryTest { @Autowired
JdbcSpittleRepository spittleRepository; @Test
public void count() {
assertEquals(15, spittleRepository.count());
} @Test
public void findRecent() {
// default case
{
List<Spittle> recent = spittleRepository.findRecent();
assertRecent(recent, 10);
} // specific count case
{
List<Spittle> recent = spittleRepository.findRecent(5);
assertRecent(recent, 5);
}
} @Test
public void findOne() {
Spittle thirteen = spittleRepository.findOne(13);
assertEquals(13, thirteen.getId().longValue());
assertEquals("Bonjour from Art!", thirteen.getMessage());
assertEquals(1332682500000L, thirteen.getPostedTime().getTime());
assertEquals(4, thirteen.getSpitter().getId().longValue());
assertEquals("artnames", thirteen.getSpitter().getUsername());
assertEquals("password", thirteen.getSpitter().getPassword());
assertEquals("Art Names", thirteen.getSpitter().getFullName());
assertEquals("art@habuma.com", thirteen.getSpitter().getEmail());
assertTrue(thirteen.getSpitter().isUpdateByEmail());
} @Test
public void findBySpitter() {
List<Spittle> spittles = spittleRepository.findBySpitterId(4L);
assertEquals(11, spittles.size());
for (int i = 0; i < 11; i++) {
assertEquals(15 - i, spittles.get(i).getId().longValue());
}
} @Test
@Transactional
public void save() {
assertEquals(15, spittleRepository.count());
Spitter spitter = spittleRepository.findOne(13).getSpitter();
Spittle spittle = new Spittle(null, spitter, "Un Nuevo Spittle from Art",
new Date());
Spittle saved = spittleRepository.save(spittle);
assertEquals(16, spittleRepository.count());
assertNewSpittle(saved);
assertNewSpittle(spittleRepository.findOne(16L));
} @Test
@Transactional
public void delete() {
assertEquals(15, spittleRepository.count());
assertNotNull(spittleRepository.findOne(13));
spittleRepository.delete(13L);
assertEquals(14, spittleRepository.count());
assertNull(spittleRepository.findOne(13));
} private void assertRecent(List<Spittle> recent, int count) {
long[] recentIds = new long[] { 3, 2, 1, 15, 14, 13, 12, 11, 10, 9 };
assertEquals(count, recent.size());
for (int i = 0; i < count; i++) {
assertEquals(recentIds[i], recent.get(i).getId().longValue());
}
} private void assertNewSpittle(Spittle spittle) {
assertEquals(16, spittle.getId().longValue());
} }

SPRING IN ACTION 第4版笔记-第十章Hitting the database with spring and jdbc-002-本章的源代码的更多相关文章

  1. SPRING IN ACTION 第4版笔记-第十章Hitting the database with spring and jdbc-003-四种方式获取DataSource

    一.概述 1.Spring offers several options for configuring data-source beans in your Spring application, i ...

  2. SPRING IN ACTION 第4版笔记-第十章Hitting the database with spring and jdbc-001-Spring对原始JDBC的封装

    1.spring扩展的jdbc异常 2.Template的运行机制 Spring separates the fixed and variable parts of the data-access p ...

  3. SPRING IN ACTION 第4版笔记-第十章Hitting the database with spring and jdbc-004-使用NamedParameterJdbcTemplate

    为了使查询数据库时,可以使用命名参数,则要用NamedParameterJdbcTemplate 1.Java文件配置 @Bean public NamedParameterJdbcTemplate ...

  4. SPRING IN ACTION 第4版笔记-第七章Advanced Spring MVC-005- 异常处理@ResponseStatus、@ExceptionHandler、@ControllerAdvice

    No matter what happens, good or bad, the outcome of a servlet request is a servlet response. If an e ...

  5. SPRING IN ACTION 第4版笔记-第六章RENDERING WEB VIEWS-002- Spring的JSP标签之form标签(<sf:input><sf:errors><sf:form>)

    一. Spring offers two JSP tag libraries to help define the view of your Spring MVC web views. One tag ...

  6. SPRING IN ACTION 第4版笔记-第五章BUILDING SPRING WEB APPLICATIONS-007-表单验证@Valid、Error

    一. Starting with Spring 3.0, Spring supports the Java Validation API in Spring MVC . No extra config ...

  7. SPRING IN ACTION 第4版笔记-第四章ASPECT-ORIENTED SPRING-003-Spring对AOP支持情况的介绍

    一. 不同的Aop框架在支持aspect何时.如何织入到目标中是不一样的.如AspectJ和Jboss支持在构造函数和field被修改时织入,但spring不支持,spring只支持一般method的 ...

  8. SPRING IN ACTION 第4版笔记-第一章-005-Bean的生命周期

    一. 1. As you can see, a bean factory performs several setup steps before a bean is ready touse. Let’ ...

  9. Spring In Action 第4版笔记-第一章-001架构

    1.Spring’s fundamental mission: Spring simplifies Java development. 2.To back up its attack on Java ...

随机推荐

  1. 从JetBrains公司产品给我的商业模式启示

    JetBrains是捷克一家公司,专门从事IDE工具的开发,运营的产品有十几个.我因为使用JavaScript IDE工具而了解了WebStorm.进而了解了开发WebStorm的公司JetBrian ...

  2. js之Function原型

    在ECMAScript中,Function(函数)类型实际上是对象.每个函数都是Function类型的实例,而且都与其他引用类型一样具有属性和方法.由于函数是对象,因此函数名实际上也是一个指向函数对象 ...

  3. 【每日scrum】NO.2

    1.今天找到了铁大电子地图. 2.需求分析未完成,进度有点慢.

  4. C# 串口通信总结

    在C#串口通信开发过程中有的产家只提供通信协议,这时候开发人员要自己根据协议来封装方法,有的产家比较人性化提供了封装好的通信协议方法供开发人员调用. 1.只提供通信协议(例如,今年早些时候开发的出钞机 ...

  5. codeforces399D

    题目大意:ainta刷一面n*n的二维墙.墙一开始可能有一些块被刷了.他终止刷墙的前提是墙的每一行每一列都至少有一块被刷.他每一次从n*n的墙随机选择一块,如果这一块没有被刷就刷,刷了就无视,刷墙不计 ...

  6. bzoj 2327 构图暴力判断+独立集个数

    首先我们可以处理出10^6以内的所有的勾股数,如果我们有2*i-1和2*j互质, 那么A=(2*i-1)*(2*i-1)+(2*i-1)*(2*j),B=2*j*j+(2*i-1)*(2*j)为互质 ...

  7. 【BZOJ】【1018】【SHOI2008】堵塞的交通traffic

    线段树 这题的线段树+分类讨论蛮神奇的……我以前学的线段树简直就是渣渣QAQ 看了下ydc题解里的思想>_>用线段树维护连通性!那么就自己写吧……每个节点表示一段区间的连通性(我的叶子节点 ...

  8. Silverlight编程模型

    Silverlight支持Javascript API编程模型和托管API编程模型这两种编程模型,它们的基本作用都是用于XAML界面文件中的XAML对象,基于托管API编程的XAML应用程序是通过x: ...

  9. atan atan2的区别!

    atan与atan2的使用=范围不一样! 今天调一一下午的BUG!终于发现了是ATAN的错! atan()函数: atan(y/x); 带一个参数!注意X不能为0,否则…………, 还有求出的角度为-p ...

  10. Android 4.4 KitKat, the browser and the Chrome WebView

    Having V8 as the JavaScript engine for the new web view, the JavaScript performance if much better, ...