<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                tips:java代碼注釋的模板 ~~~ /\*\* \* ${tags} \*//\*\* \* ${tags} \* ${return\_type} \* @author 李淼 \* @time ${date}${time} \*//\* (non-Javadoc) \* ${see\_to\_overridden} \*//\*\* \* \*//\*\* \* @param ${param} the ${bare\_field\_name} to set \*//\*\* \* @project\_name ${project\_name} \* @package\_name ${package\_name} \* @class\_name ${type\_name} \* @author 李淼 \* @company yhouse \* @version 1.0 \* @time ${date}? ${time} \*//\*\* \* @return the ${bare\_field\_name} \*//\*\* \* ${tags} \* ${see\_to\_target} \*//\*\* \* \*/ ~~~ 使用說明: 1.新建xml文件,將上面的內容粘貼到里面 2.在myeclipse中? window-preference ? java-CodeTemplate ? import導入 ![](https://box.kancloud.cn/0635228d1374eb7db0fae7a5c18d61fb_708x517.png) 6.7.1. 需求 根據商品 ID 查詢商品信息,返回 json 數據。 6.7.2. Dao 層的實現 逆向工程已經生產了底層的代碼,當前業務需要的功能已經實現,所以不用在寫代碼。 6.7.3. Service 實現 在 interface 中添加接口 ItemService ![](https://box.kancloud.cn/2c9d6c326144b8e938f4f648c5bfc884_325x94.png) 方法需求:傳入參數 itemId,返回值為 TbItem 對象。 ~~~ package com.igeek.egobuy.service; import com.igeek.egobuy.pojo.TbItem; /** * @project_name buy-manager-interface * @package_name com.igeek.egobuy.service * @class_name ItemService * @author limiao * @Description:商品服務接口 * @company yhouse * @version 1.0 * @time 2019年1月12日 下午12:43:41 */ public interface ItemService { /** * * @param itemId * @return * TbItem * 通過id查詢商品 * @author limiao * @time 2019年1月12日下午12:45:42 */ TbItem getById(long itemId); } ~~~ 在 service 工程中添加 ItemServiceImpl 實現類 ![](https://box.kancloud.cn/70db6f8d78b9b650d8143bd91e2b52b1_291x92.png) ~~~ package com.igeek.egobuy.service.impl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.igeek.egobuy.mapper.TbItemMapper; import com.igeek.egobuy.pojo.TbItem; import com.igeek.egobuy.service.ItemService; /** * @project_name buy-manager-service * @package_name com.igeek.egobuy.service.impl * @class_name ItemServiceImpl * @author limiao * @Description:商品的服務實現類 * @company yhouse * @version 1.0 * @time 2019年1月12日 下午12:47:22 */ @Service public class ItemServiceImpl implements ItemService { @Autowired private TbItemMapper tbItemMapper; /* (non-Javadoc) * @see com.igeek.egobuy.service.ItemService#getById(long) */ @Override public TbItem getById(long itemId) { // TODO Auto-generated method stub //直接通過id查詢 TbItem tbItem = tbItemMapper.selectByPrimaryKey(itemId); return tbItem; //條件查詢 // TbItem item=null; // TbItemExample example=new TbItemExample(); // Criteria criteria = example.createCriteria(); // criteria.andIdEqualTo(itemId); // List<TbItem> items = tbItemMapper.selectByExample(example); // if(items.size()>0){ // item=items.get(0); // } // return item; } } ~~~ 6.7.4. Controller 層的實現 在 web 工程中添加 ItemController 類 ~~~ package com.igeek.egobuy.controller; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import com.igeek.egobuy.pojo.TbItem; import com.igeek.egobuy.service.ItemService; /** * @project_name buy-manager-web * @package_name com.igeek.egobuy.controller * @class_name ItemController * @author limiao * @Description:商品的表現層 * @company yhouse * @version 1.0 * @time 2019年1月12日 下午1:01:42 */ @Controller public class ItemController { @Autowired private ItemService itemService; @RequestMapping("/item") @ResponseBody public TbItem getItemById(@RequestParam("id")Long itemId){ TbItem item = itemService.getById(itemId); return item; } } ~~~ 6.7.5. Mapper 綁定異常解決 啟動項目,訪問時會出現如下異常: ![](https://box.kancloud.cn/0c842380aa6513f3501990ad604c57b7_1289x649.png) 原因:逆向工程生成的 mapper 文件沒有打包到項目中。 解決方案: 在 buy-manager-dao 工程的 pom 文件中添加如下配置: ~~~ <!-- 如果不添加此節點mybatis的mapper.xml文件都會被漏掉。 --> <build> <resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.properties</include> <include>**/*.xml</include> </includes> <filtering>false</filtering> </resource> </resources> </build> ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看