JBOSS 點(diǎn)滴

          豐豐的博客

          2018年8月25日 #

          mysql5.x忘記密碼

          參考:https://blog.csdn.net/qq_34102150/article/details/126120056


          1、停止MySQL服務(wù),輸入 net stop mysql 停止服務(wù)。
          2、切換到MySQL的bin文件下,
              mysql5.x:  mysqld --console --skip-grant-tables --shared-memory

          mysqld --console --skip-grant-tables --shared-memory
          3、輸入mysql -uroot -p回車,不用輸入密碼,直接按回車跳過(guò),
              輸入:  use mysql 
              輸入:  update user set password=PASSWORD('123456') where USER='root';
              或者:   GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY '123456' WITH GRANT OPTION;
              輸入:  FLUSH PRIVILEGES;
          4、重啟服務(wù)

          posted @ 2024-02-17 15:09 半導(dǎo)體 閱讀(45) | 評(píng)論 (0)編輯 收藏

          微信小程序開(kāi)發(fā)流程

          準(zhǔn)備工作:
              需要https的域名
              1、域名申請(qǐng)、備案   (我是在阿里云買的服務(wù)器,域名也在阿里云購(gòu)買  )
              2、域名與IP綁定 
              3、ssl安全證書(shū) 申請(qǐng)(https
              4、下載ssl安全證書(shū)布署在tomcat服務(wù)器
              4、在云服務(wù)器tomcat中布署https           
                     參考   https://blog.csdn.net/qq_35206244/article/details/97613498

                    ps:任何操作不會(huì),直接打阿里云客服電話 95187
              
          小程序開(kāi)發(fā)流程:
              1、在微信官網(wǎng)注冊(cè)帳號(hào)
              2、下載小程序開(kāi)發(fā)工具
              3、小程序開(kāi)發(fā)、上傳   
              4、小程序送審,審核通過(guò)即可分享給你的朋友

          posted @ 2020-08-08 10:11 半導(dǎo)體 閱讀(119) | 評(píng)論 (0)編輯 收藏

          mall 工程創(chuàng)建踩坑

          新建項(xiàng)目坑 
          www.macrozheng.com項(xiàng)目,打開(kāi)maven總是引入失敗,后來(lái)
          https://www.cnblogs.com/dk1024/p/10778841.html


          https://blog.csdn.net/ken_ding/article/details/85623092這個(gè)是前端有可能遇見(jiàn)的坑的解決辦法


           安裝環(huán)境文檔:
          http://www.macrozheng.com/#/deploy/mall_deploy_windows

          posted @ 2020-07-20 21:52 半導(dǎo)體 閱讀(123) | 評(píng)論 (0)編輯 收藏

          springboot 打包 后,在dos命令行運(yùn)行提示沒(méi)有主清單屬性的解決辦法

          1.在pom.xml文件中插入
          <build>
              <plugins>
                  <plugin>
                      <groupId>org.springframework.boot</groupId>
                      <artifactId>spring-boot-maven-plugin</artifactId>
                  </plugin>
              </plugins>
          </build>
          2.雙擊IDEA右側(cè)Maven Projects的lifecycle下的package,打包成jar,重新執(zhí)行以上命令。

          posted @ 2020-06-27 16:42 半導(dǎo)體 閱讀(216) | 評(píng)論 (0)編輯 收藏

          MyBatis出現(xiàn)org.apache.ibatis.executor.ExecutorException異常

          DEBUG [main] - PooledDataSource forcefully closed/removed all connections.
          DEBUG [main] 
          - PooledDataSource forcefully closed/removed all connections.
          DEBUG [main] 
          - PooledDataSource forcefully closed/removed all connections.
          DEBUG [main] 
          - PooledDataSource forcefully closed/removed all connections.
          DEBUG [main] 
          - Opening JDBC Connection
          DEBUG [main] 
          - Created connection 29011566.
          DEBUG [main] 
          - Setting autocommit to false on JDBC Connection [com.mysql.jdbc.JDBC4Connection@1baae6e]
          DEBUG [main] 
          - ==>  Preparing: select * from user where username like concat(?,'%') 
          DEBUG [main] - ==> Parameters: 張(String)

          org.apache.ibatis.exceptions.PersistenceException: 
          ### 
          Error querying database.  Cause: org.apache.ibatis.executor.result.ResultMapException: Error attempting to get column 'username' from result set.  Cause: java.sql.SQLException: Cannot convert value 'å¼ ä¸?' from column 2 to TIMESTAMP.
          ### The error may exist in sqlmap/User.xml
          ### The 
          error may involve test.findUserByName3
          ### The 
          error occurred while handling results
          ### SQL: 
          select * from user where username like concat(?,'%')
          ### Cause: org.apache.ibatis.executor.result.ResultMapException: Error attempting to get column 'username' from result set.  Cause: java.sql.SQLException: Cannot convert value 'å¼ ä¸?' from column 2 to TIMESTAMP.

              at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:
          30)
              at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:
          149)
              at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:
          140)
              at com.swjd.test.B.test2(B.java:
          40)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
          62)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
          43)
              at java.lang.reflect.Method.invoke(Method.java:
          497)
              at org.junit.runners.model.FrameworkMethod$
          1.runReflectiveCall(FrameworkMethod.java:50)
              at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:
          12)
              at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:
          47)
              at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:
          17)
              at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:
          325)
              at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:
          78)
              at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:
          57)
              at org.junit.runners.ParentRunner$
          3.run(ParentRunner.java:290)
              at org.junit.runners.ParentRunner$
          1.schedule(ParentRunner.java:71)
              at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:
          288)
              at org.junit.runners.ParentRunner.access$
          000(ParentRunner.java:58)
              at org.junit.runners.ParentRunner$
          2.evaluate(ParentRunner.java:268)
              at org.junit.runners.ParentRunner.run(ParentRunner.java:
          363)
              at org.junit.runner.JUnitCore.run(JUnitCore.java:
          137)
              at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:
          68)
              at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:
          47)
              at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:
          242)
              at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:
          70)
          Caused by: org.apache.ibatis.executor.result.ResultMapException: 
          Error attempting to get column 'username' from result set.  Cause: java.sql.SQLException: Cannot convert value 'å¼ ä¸?' from column 2 to TIMESTAMP.
              at org.apache.ibatis.type.BaseTypeHandler.getResult(BaseTypeHandler.java:83)
              at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.createUsingConstructor(DefaultResultSetHandler.java:
          671)
              at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.createByConstructorSignature(DefaultResultSetHandler.java:
          654)
              at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.createResultObject(DefaultResultSetHandler.java:
          618)
              at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.createResultObject(DefaultResultSetHandler.java:
          591)
              at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getRowValue(DefaultResultSetHandler.java:
          397)
              at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValuesForSimpleResultMap(DefaultResultSetHandler.java:
          354)
              at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValues(DefaultResultSetHandler.java:
          328)
              at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSet(DefaultResultSetHandler.java:
          301)
              at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSets(DefaultResultSetHandler.java:
          194)
              at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:
          65)
              at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:
          79)
              at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:
          63)
              at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:
          324)
              at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:
          156)
              at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:
          109)
              at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:
          83)
              at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:
          147)
               
          24 more
          Caused by: java.sql.SQLException: Cannot convert value 
          'å¼ ä¸?' from column 2 to TIMESTAMP.
              at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
              at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:
          956)
              at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:
          926)
              at com.mysql.jdbc.ResultSetRow.getTimestampFast(ResultSetRow.java:
          1328)
              at com.mysql.jdbc.ByteArrayRow.getTimestampFast(ByteArrayRow.java:
          124)
              at com.mysql.jdbc.ResultSetImpl.getTimestampInternal(ResultSetImpl.java:
          6669)
              at com.mysql.jdbc.ResultSetImpl.getTimestamp(ResultSetImpl.java:
          5988)
              at com.mysql.jdbc.ResultSetImpl.getTimestamp(ResultSetImpl.java:
          6026)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
          62)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
          43)
              at java.lang.reflect.Method.invoke(Method.java:
          497)
              at org.apache.ibatis.logging.jdbc.ResultSetLogger.invoke(ResultSetLogger.java:
          69)
              at com.sun.proxy.$Proxy6.getTimestamp(Unknown Source)
              at org.apache.ibatis.type.DateTypeHandler.getNullableResult(DateTypeHandler.java:
          39)
              at org.apache.ibatis.type.DateTypeHandler.getNullableResult(DateTypeHandler.java:
          28)
              at org.apache.ibatis.type.BaseTypeHandler.getResult(BaseTypeHandler.java:
          81)
               
          41 more
          Caused by: java.lang.NumberFormatException: 張三
              at com.mysql.jdbc.StringUtils.getInt(StringUtils.java:
          756)
              at com.mysql.jdbc.ResultSetRow.getTimestampFast(ResultSetRow.java:
          1253)
               
          54 more


          Process finished 
          with exit code -1

          上網(wǎng)找了一些答案也沒(méi)有解決我的問(wèn)題,

          后來(lái)發(fā)現(xiàn)原來(lái)是User類的構(gòu)造函數(shù)問(wèn)題,找不到相關(guān)的構(gòu)造函數(shù);試著在User中加一個(gè)默認(rèn)的構(gòu)造函數(shù),就解決了。。。

          希望能幫到大家。

                   默認(rèn)的構(gòu)造函數(shù)在創(chuàng)建構(gòu)造函數(shù)后,不會(huì)自動(dòng)創(chuàng)建默認(rèn)構(gòu)造函數(shù)

          DEBUG [main] 
          - Logging initialized using 'class org.apache.ibatis.logging.slf4j.Slf4jImpl' adapter.
          DEBUG [main] - PooledDataSource forcefully closed/removed all connections.
          DEBUG [main] 
          - PooledDataSource forcefully closed/removed all connections.
          DEBUG [main] 
          - PooledDataSource forcefully closed/removed all connections.
          DEBUG [main] 
          - PooledDataSource forcefully closed/removed all connections.
          DEBUG [main] 
          - Opening JDBC Connection
          DEBUG [main] 
          - Created connection 27155935.
          DEBUG [main] 
          - Setting autocommit to false on JDBC Connection [com.mysql.jdbc.JDBC4Connection@19e5ddf]
          DEBUG [main] 
          - ==>  Preparing: select * from user where id=
          DEBUG [main] 
          - ==> Parameters: 27(Integer)

          org.apache.ibatis.exceptions.PersistenceException: 
          ### 
          Error querying database.  Cause: org.apache.ibatis.reflection.ReflectionException: Error instantiating class com.swjd.po.User with invalid types () or values (). Cause: java.lang.NoSuchMethodException: com.swjd.po.User.<init>()
          ### The 
          error may exist in sqlmap/User.xml
          ### The 
          error may involve test.findUserById-Inline
          ### The 
          error occurred while setting parameters
          ### SQL: 
          select * from user where id=?
          ### Cause: org.apache.ibatis.reflection.ReflectionException: 
          Error instantiating class com.swjd.po.User with invalid types () or values (). Cause: java.lang.NoSuchMethodException: com.swjd.po.User.<init>()

              at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:
          26)
              at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:
          111)
              at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:
          102)
              at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:
          66)
              at com.test.Test1.test1(Test1.java:
          31)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
          62)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
          43)
              at java.lang.reflect.Method.invoke(Method.java:
          497)
              at org.junit.runners.model.FrameworkMethod$
          1.runReflectiveCall(FrameworkMethod.java:50)
              at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:
          12)
              at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:
          47)
              at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:
          17)
              at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:
          325)
              at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:
          78)
              at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:
          57)
              at org.junit.runners.ParentRunner$
          3.run(ParentRunner.java:290)
              at org.junit.runners.ParentRunner$
          1.schedule(ParentRunner.java:71)
              at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:
          288)
              at org.junit.runners.ParentRunner.access$
          000(ParentRunner.java:58)
              at org.junit.runners.ParentRunner$
          2.evaluate(ParentRunner.java:268)
              at org.junit.runners.ParentRunner.run(ParentRunner.java:
          363)
              at org.junit.runner.JUnitCore.run(JUnitCore.java:
          137)
              at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:
          68)
              at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:
          47)
              at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:
          242)
              at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:
          70)
          Caused by: org.apache.ibatis.reflection.ReflectionException: 
          Error instantiating class com.swjd.po.User with invalid types () or values (). Cause: java.lang.NoSuchMethodException: com.swjd.po.User.<init>()
              at org.apache.ibatis.reflection.factory.DefaultObjectFactory.instantiateClass(DefaultObjectFactory.java:
          86)
              at org.apache.ibatis.reflection.factory.DefaultObjectFactory.create(DefaultObjectFactory.java:
          48)
              at org.apache.ibatis.reflection.factory.DefaultObjectFactory.create(DefaultObjectFactory.java:
          41)
              at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.createResultObject(DefaultResultSetHandler.java:
          528)
              at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.createResultObject(DefaultResultSetHandler.java:
          507)
              at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getRowValue(DefaultResultSetHandler.java:
          331)
              at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValuesForSimpleResultMap(DefaultResultSetHandler.java:
          291)
              at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValues(DefaultResultSetHandler.java:
          266)
              at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSet(DefaultResultSetHandler.java:
          236)
              at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSets(DefaultResultSetHandler.java:
          150)
              at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:
          60)
              at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:
          73)
              at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:
          60)
              at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:
          267)
              at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:
          137)
              at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:
          96)
              at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:
          77)
              at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:
          108)
               
          25 more
          Caused by: java.lang.NoSuchMethodException: com.swjd.po.User.
          <init>()
              at java.lang.Class.getConstructor0(Class.java:
          3082)
              at java.lang.Class.getDeclaredConstructor(Class.java:
          2178)
              at org.apache.ibatis.reflection.factory.DefaultObjectFactory.instantiateClass(DefaultObjectFactory.java:
          60)
               
          42 more


          Process finished 
          with exit code -1


            

          這種錯(cuò)也是同樣的問(wèn)題,


          加上無(wú)參構(gòu)造函數(shù)就可以了。


          當(dāng)創(chuàng)建對(duì)象來(lái)接受sql結(jié)果時(shí)會(huì)遍歷實(shí)體類的構(gòu)造方法找到與之匹配的,如果實(shí)體類中有構(gòu)造方法了但是參數(shù)不匹配的話就會(huì)報(bào)上述錯(cuò)誤,此時(shí)添加無(wú)參構(gòu)造方法(默認(rèn)的構(gòu)造方法),會(huì)走其他方法,
          https://blog.csdn.net/qq_35975416/article/details/80488267




          posted @ 2020-03-25 20:01 半導(dǎo)體 閱讀(5572) | 評(píng)論 (0)編輯 收藏

          idea jsp代碼不提示Java代碼

          在<head>里寫(xiě)java代碼有提示,在<body>里不寫(xiě)%>就有提示。

          這是由于按提示快捷鍵alt+enter導(dǎo)致。解決方法一直未找到合適的。 
          解決方法:

          posted @ 2020-03-08 20:11 半導(dǎo)體 閱讀(257) | 評(píng)論 (0)編輯 收藏

          項(xiàng)目管理推薦好文

          掙值管理(PV、EV、AC、SV、CV、SPI、CPI)記憶之我見(jiàn) http://www.cnitpm.com/pm/7707.html https://blog.csdn.net/weixin_38197294/article/details/79852129

          posted @ 2020-03-08 11:41 半導(dǎo)體 閱讀(114) | 評(píng)論 (0)編輯 收藏

          jquery傳參及獲取方式

          html寫(xiě)法
          <form id="myform">
          <input type="radio" value="1" name="gender">
          <input type="radio" value="2" name="gender">
          <input type="text" name="username" />
          <input type="button" value="提交" onclick="fun()"/>
          </form>
          <div id="myText"></div>



          獲取值方式一
              <script src="js/jquery-3.3.1.min.js"></script>
              
          <script>
                  
          //定義方法
                  function fun(){
                     alert($('#myform').serialize());
                      
          //使用ajax發(fā)送異步請(qǐng)求
                        $.post("ajaxServletH",$('#myform').serialize(),function(data){
                            
          var divA = document.getElementById("myText");
                            divA.innerHTML 
          = "<br/><hr><br/>"+data;
                         },
          "text")
                  }
              
          </script>
          獲取值方式二:

          var gender = $ ("input [name= 'gender' ] : checked") .val() ;

          posted @ 2020-02-08 18:36 半導(dǎo)體 閱讀(167) | 評(píng)論 (0)編輯 收藏

          spring boot結(jié)合thymeleaf通過(guò)后臺(tái)傳入的數(shù)值循環(huán)生成標(biāo)簽

          spring boot結(jié)合thymeleaf通過(guò)后臺(tái)傳入的數(shù)值循環(huán)生成標(biāo)簽

           <span th:each="i:${#numbers.sequence(1,page.pages)}">
             
          <span th:text="${i}"/>
          </span>

          posted @ 2019-10-16 16:06 半導(dǎo)體 閱讀(337) | 評(píng)論 (0)編輯 收藏

          模態(tài)框傳值

          模態(tài)框傳值:
          https://blog.csdn.net/linhaiyun_ytdx/article/details/77417702

          posted @ 2019-10-12 16:35 半導(dǎo)體 閱讀(155) | 評(píng)論 (0)編輯 收藏

          Bootstrap 模態(tài)框 + iframe > 打開(kāi)子頁(yè)面 > 數(shù)據(jù)傳輸/關(guān)閉模態(tài)框

               摘要: 父頁(yè)面bootstrap模態(tài)框: <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="false" > <div class="modal-dialog modal-lg"> ...  閱讀全文

          posted @ 2019-05-28 21:23 半導(dǎo)體 閱讀(330) | 評(píng)論 (0)編輯 收藏

          mybatis學(xué)習(xí)之路----mysql批量新增數(shù)據(jù)

          來(lái)源:
          https://blog.csdn.net/xu1916659422/article/details/77971867
           
             mysql新增語(yǔ)句 
              insert into 表名(字段,字段。。。) values ( 值,值 。。。);此種適合單條插入。
          批量插入,
             一種可以在代碼中循環(huán)著執(zhí)行上面的語(yǔ)句,但是這種效率太差,下面會(huì)有對(duì)比,看看它有多差。
          另一種,可以用mysql支持的批量插入語(yǔ)句,
          insert into
               表名(字段,字段。。。) values ( 值,值 。。。),( 值,值 。。。),( 值,值 。。。)....
          這種方式相比起來(lái),更高效。
          實(shí)現(xiàn)過(guò)程mapper.xml
           

              <!-- 跟普通的insert沒(méi)有什么不同的地方 ,主要用來(lái)跟下面的批量插入做對(duì)比。-->
              <insert id="insert" parameterType="com.soft.mybatis.model.Customer">
                  <!-- 跟自增主鍵方式相比,這里的不同之處只有兩點(diǎn)
                              1  insert語(yǔ)句需要寫(xiě)id字段了,并且 values里面也不能省略
                              2 selectKey 的order屬性需要寫(xiě)成BEFORE 因?yàn)檫@樣才能將生成的uuid主鍵放入到model中,
                              這樣后面的insert的values里面的id才不會(huì)獲取為空
                        跟自增主鍵相比就這點(diǎn)區(qū)別,當(dāng)然了這里的獲取主鍵id的方式為 select uuid()
                        當(dāng)然也可以另寫(xiě)別生成函數(shù)。-->
                  <selectKey keyProperty="id" order="BEFORE" resultType="String">
                      select uuid()
                  </selectKey>
                  insert into t_customer (id,c_name,c_sex,c_ceroNo,c_ceroType,c_age)
                  values (#{id},#{name},#{sex},#{ceroNo},#{ceroType},#{age})
              </insert>
           
              <!-- 批量插入, -->
              <insert id="batchInsert" parameterType="java.util.Map">
                  <!-- 這里只做演示用,真正項(xiàng)目中不會(huì)寫(xiě)的這么簡(jiǎn)單。 -->
                  insert into
                    t_customer (id,c_name,c_sex,c_ceroNo,c_ceroType,c_age)
                  values
                  <!-- foreach mybatis循環(huán)集合用的
                        collection="list" 接收的map集合中的key 用以循環(huán)key對(duì)應(yīng)的屬性
                           separator=","  表示每次循環(huán)完畢,在sql后面放一個(gè)逗號(hào)
                           item="cus" 每次循環(huán)的實(shí)體對(duì)象 名稱隨意-->
                  <foreach collection="list" separator="," item="cus">
                      <!-- 組裝values對(duì)象,因?yàn)檫@張表的主鍵為非自增主鍵,所以這里 (select uuid()) 用于生成id的值-->
                      ((select uuid()),#{cus.name},#{cus.sex},#{cus.ceroNo},#{cus.ceroType},#{cus.age})
                  </foreach>
              </insert>
          實(shí)體model對(duì)象

          package com.soft.mybatis.model;

           

          /**

           * Created by xuweiwei on 2017/9/10.

           */

          public class Customer {

           

              private String id;

              private String name;

              private Integer age;

              private Integer sex;

              private String ceroNo;

              private Integer ceroType;

           

              public String getId() {

                  return id;

              }

           

              public void setId(String id) {

                  this.id = id;

              }

           

              public String getName() {

                  return name;

              }

           

              public void setName(String name) {

                  this.name = name;

              }

           

              public Integer getAge() {

                  return age;

              }

           

              public void setAge(Integer age) {

                  this.age = age;

              }

           

              public Integer getSex() {

                  return sex;

              }

           

              public void setSex(Integer sex) {

                  this.sex = sex;

              }

           

              public String getCeroNo() {

                  return ceroNo;

              }

           

              public void setCeroNo(String ceroNo) {

                  this.ceroNo = ceroNo;

              }

           

              public Integer getCeroType() {

                  return ceroType;

              }

           

              public void setCeroType(Integer ceroType) {

                  this.ceroType = ceroType;

              }

           

              @Override

              public String toString() {

                  return "Customer{" +

                          "id='" + id + '\'' +

                          ", name='" + name + '\'' +

                          ", age=" + age +

                          ", sex=" + sex +

                          ", ceroNo='" + ceroNo + '\'' +

                          ", ceroType='" + ceroType + '\'' +

                          '}';

              }

          }
          接口
          1. int add(Customer customer);
          2.     int batchInsert(Map<String,Object> param);

            實(shí)現(xiàn)
          實(shí)現(xiàn)

             
          /**

               * 新增數(shù)據(jù)

               * 
          @param customer

               * 
          @return

               
          */

              
          public int add(Customer customer) {

                  
          return insert("customer.insert", customer);

              }

           

              
          /**

               * 批量插入數(shù)據(jù)

               * 
          @param param

               * 
          @return

               
          */

              
          public int batchInsert(Map<String,Object> param) {

                  
          return insert("customer.batchInsert", param);

              }

           

              
          /**

               * 公共部分

               * 
          @param statementId

               * 
          @param obj

               * 
          @return

               
          */

              
          private int insert(String statementId, Object obj){

                  SqlSession sqlSession 
          = null;

                  
          try {

                      sqlSession 
          = SqlsessionUtil.getSqlSession();

                      
          int key =  sqlSession.insert(statementId, obj);

                      
          // commit

                      sqlSession.commit();

                      
          return key;

                  } 
          catch (Exception e) {

                      sqlSession.rollback();

                      e.printStackTrace();

                  } 
          finally {

                      SqlsessionUtil.closeSession(sqlSession);

                  }

                  
          return 0;

              }

          posted @ 2019-05-23 11:29 半導(dǎo)體 閱讀(137) | 評(píng)論 (0)編輯 收藏

          springboot中樹(shù)形結(jié)構(gòu)的開(kāi)發(fā)

          POM中引入
                  <!--JSON樹(shù)形結(jié)構(gòu) 轉(zhuǎn)換-->
                  
          <dependency>
                      
          <groupId>net.sf.json-lib</groupId>
                      
          <artifactId>json-lib</artifactId>
                      
          <version>2.4</version>
                      
          <classifier>jdk15</classifier>
                  
          </dependency>
          實(shí)體類創(chuàng)建
          import net.sf.json.JSONArray;

          import java.util.ArrayList;
          import java.util.List;

          /**
           * 構(gòu)造目錄JSON樹(shù)
           * Created by   network on 2019/5/22
           
          */
          public class TreeBuilder {

              List
          <Node> nodes = new ArrayList<>();

              
          public String buildTree(List<Node> nodes) {

                  TreeBuilder treeBuilder 
          = new TreeBuilder(nodes);

                  
          return treeBuilder.buildJSONTree();
              }

              
          public TreeBuilder() {
              }

              
          public TreeBuilder(List<Node> nodes) {
                  
          super();
                  
          this.nodes = nodes;
              }

              
          // 構(gòu)建JSON樹(shù)形結(jié)構(gòu)
              public String buildJSONTree() {
                  List
          <Node> nodeTree = buildTree();
                  JSONArray jsonArray 
          = JSONArray.fromObject(nodeTree);
                  
          return jsonArray.toString();
              }

              
          // 構(gòu)建樹(shù)形結(jié)構(gòu)
              public List<Node> buildTree() {
                  List
          <Node> treeNodes = new ArrayList<>();
                  List
          <Node> rootNodes = getRootNodes();
                  
          for (Node rootNode : rootNodes) {
                      buildChildNodes(rootNode);
                      treeNodes.add(rootNode);
                  }
                  
          return treeNodes;
              }

              
          // 遞歸子節(jié)點(diǎn)
              public void buildChildNodes(Node node) {
                  List
          <Node> children = getChildNodes(node);
                  
          if (!children.isEmpty()) {
                      
          for (Node child : children) {
                          buildChildNodes(child);
                      }
                      node.setChildren(children);
                  }
              }

              
          // 獲取父節(jié)點(diǎn)下所有的子節(jié)點(diǎn)
              public List<Node> getChildNodes(Node pnode) {
                  List
          <Node> childNodes = new ArrayList<>();
                  
          for (Node n : nodes) {
                      
          if (pnode.getId().equals(n.getPid())) {
                          childNodes.add(n);
                      }
                  }
                  
          return childNodes;
              }

              
          // 判斷是否為根節(jié)點(diǎn)
              public boolean rootNode(Node node) {
                  
          boolean isRootNode = true;
                  
          for (Node n : nodes) {
                      
          if (node.getPid().equals(n.getId())) {
                          isRootNode 
          = false;
                          
          break;
                      }
                  }
                  
          return isRootNode;
              }

              
          // 獲取集合中所有的根節(jié)點(diǎn)
              public List<Node> getRootNodes() {
                  List
          <Node> rootNodes = new ArrayList<>();
                  
          for (Node n : nodes) {
                      
          if (rootNode(n)) {
                          rootNodes.add(n);
                      }
                  }
                  
          return rootNodes;
              }

              
          public static class Node {

                  
          private String id;
                  
          private String pid;
                  
          private String name;
                  
          private List<Node> children;

                  
          public Node() {
                  }

                  
          public Node(String id, String pid, String name) {
                      
          super();
                      
          this.id = id;
                      
          this.pid = pid;
                      
          this.name = name;
                  }

                  
          public String getId() {
                      
          return id;
                  }

                  
          public void setId(String id) {
                      
          this.id = id;
                  }

                  
          public String getPid() {
                      
          return pid;
                  }

                  
          public void setPid(String pid) {
                      
          this.pid = pid;
                  }

                  
          public String getName() {
                      
          return name;
                  }

                  
          public void setName(String name) {
                      
          this.name = name;
                  }


                  
          public List<Node> getChildren() {
                      
          return children;
                  }

                  
          public void setChildren(List<Node> children) {
                      
          this.children = children;
                  }
              }
          }
          mapper.xml
              <!--根據(jù)條件查詢返回Node-->
              
          <select id="findByItemtypeTree" parameterType="BsItemtype" resultType="Node">
                  SELECT upcode as pid,itemname as name,itemtypecode as id FROM 表名 WHERE 1=1
                  
          <if test="upcode != null  and upcode != '' ">
                      and upcode = #{值}
                  
          </if>
              
          </select>
          controller:返回結(jié)果
              //樹(shù)形結(jié)構(gòu)
              @RequestMapping("left")
              ModelAndView left() 
          throws JSONException {
                  String mavStr 
          = "";
                  BsItemtype queryItemtype 
          = new BsItemtype();
                  
          //查詢根目錄樹(shù)
                
          //  queryItemtype.setUpcode("00");
                  
          // 獲取全部目錄節(jié)點(diǎn)
                  List<TreeBuilder.Node> itemtypeTree = itemtypeService.findByItemtypeTree();

                  
          // 拼裝樹(shù)形json字符串
                   mavStr = new TreeBuilder().buildTree(itemtypeTree);
                  mavStr 
          = mavStr.replaceAll("\"children\"","\"nodes\"");
                  mavStr
          = mavStr.replaceAll("\"id\"","\"value\"");
                  mavStr 
          = mavStr.replaceAll("\"name\"","\"text\"");
                  ModelAndView mav 
          = new ModelAndView("/bs/itemtype/itemtypeLeft.html");//配置返回路徑
                  System.out.println(mavStr);
                  mav.addObject(
          "mavStr", mavStr.toString());
                  
          return mav;
              }
          DAO層:
          List<TreeBuilder.Node> findByItemtypeTree();

          html
          <!DOCTYPE html>
          <html xmlns:th="http://www.thymeleaf.org">
          <html lang="en">
          <head>
              
          <meta charset="UTF-8">
              
          <title></title>

              
          <!-- Required Stylesheets -->
              
          <link href="/oastyle/css/bootstrap.css" rel="stylesheet">
              
          <!-- Required Javascript -->
              
          <script src="/js/jquery.js"></script>
              
          <script src="/js//bootstrap-treeview.js"></script>
          </head>
          <body>
          <div id="tree"></div>
          <script th:inline="javascript">
          var tree = eval([[${mavStr}]]);
                   
          function getTree() {
                  
          // Some logic to retrieve, or generate tree structure
                  return tree;
              }

              $('#tree').treeview({
                  data: getTree(),
                  enableLinks: 
          true});

              $('#tree').on('nodeSelected',
          function(event, data) {
                    window.parent.itemtypeRight.location.href
          ="/itemtype/list?upcode="+data.value;
              });

          </script>

          </body>
          </html>

          posted @ 2019-05-21 19:08 半導(dǎo)體 閱讀(2072) | 評(píng)論 (0)編輯 收藏

          技巧

          layui
          可以做表格排序。

          posted @ 2019-05-16 21:14 半導(dǎo)體 閱讀(82) | 評(píng)論 (0)編輯 收藏

          分頁(yè)方式:

          前臺(tái):
          <form   method="post" action = "/bbs/list"  id="queryform">
                  
          <input type="hidden" name="start" id="start"/>
                  
          <li>搜索:</li>
                          
          <input type="text" placeholder="請(qǐng)輸入公告名稱" name="title"  th:value ="${queryBbs.title}" />
                        
          <href="javascript:void(0)" class="button border-main icon-search" onclick="changesearch()" > 搜索</a>
              
          </form>
              //搜索
              function changesearch() {
                  $(
          "#queryform").submit();
              }
          通過(guò)page傳值
          <div class="pagelist" th:include="common/footer::page"/>
          包含頁(yè)面
          <!--fotter-->
          <div class="pagelist" th:fragment="page">
              
          <a th:onclick="javascript:page(0)">[首 頁(yè)]</a>
              
          <a th:onclick="javascript:page([[${page.pageNum}]]-1)">[上一頁(yè)]</a>
              
          <a th:onclick="javascript:page([[${page.pageNum}]]+1)">[下一頁(yè)]</a>
              
          <a th:onclick="javascript:page([[${page.pages}]])">[尾 頁(yè)]</a>
              共[[${page.total}]]條記錄
          </div>
          //分頁(yè)跳轉(zhuǎn)方法
          function page(pageNum) {
          $(
          "#start").val(pageNum);
          $(
          "#queryform").submit();
          }
          此種方法可以將搜索查詢框內(nèi)容通過(guò)form表單的方式提交給controller,controller再分頁(yè),但點(diǎn)“下一頁(yè)”事件多點(diǎn)二次很容易導(dǎo)致瀏覽器假死。

          第二種方式:直接通過(guò)href傳值,這種方式不死機(jī)。
                                  <div class="pagelist">
                                  
          <th:href="@{/bbs/list(start=0,title=${queryBbs.title})}">[首  頁(yè)]</a>
                                  
          <th:href="@{/bbs/list(start=${page.pageNum-1},title=${queryBbs.title})}">[上一頁(yè)]</a>
                                  
          <th:href="@{/bbs/list(start=${page.pageNum+1},title=${queryBbs.title})}">[下一頁(yè)]</a>
                                  
          <th:href="@{/bbs/list(start=${page.pages},title=${queryBbs.title})}">[尾  頁(yè)]</a>
                                      共[[${page.total}]]條記錄
                                  
          </div>

          posted @ 2019-05-15 15:21 半導(dǎo)體 閱讀(122) | 評(píng)論 (0)編輯 收藏

          org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing

               摘要: 錯(cuò)誤如下:Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->org.thymeleaf.exceptions.TemplateInputException: An error happened during&nbs...  閱讀全文

          posted @ 2019-05-12 15:15 半導(dǎo)體 閱讀(7839) | 評(píng)論 (0)編輯 收藏

          好看的界面

          windows風(fēng)格
          https://www.toufu.xyz
          layui

          網(wǎng)頁(yè)模板素材
          http://www.htmlsucai.com/forum-78-1.html
          http://www.cssmoban.com/cssthemes/houtaimoban/
          http://www.16sucai.com/
          https://www.58pic.com/

          posted @ 2019-05-11 23:17 半導(dǎo)體 閱讀(102) | 評(píng)論 (0)編輯 收藏

          Spring+Mybatis 查詢所有數(shù)據(jù)時(shí)發(fā)生異常:org.apache.ibatis.reflection.ReflectionException: There is no getter for

          Spring+Mybatis框架整合時(shí),根據(jù)條件查詢數(shù)據(jù),發(fā)生異常
          Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'sname' in 'class java.lang.String'
          userinfoMapper.xml文件:
          <select id="findAll" parameterType="string" resultMap="userinfoMap">  select * from userinfo where sname like '%${sname}%' </select>
          UserinfoMapper接口:

          public List<Userinfo> findAll(String sname);
          解決方法:在參數(shù)前加@Param標(biāo)簽
          public List<Userinfo> findAll(@Param("sname") String sname);

          posted @ 2019-05-11 16:05 半導(dǎo)體 閱讀(1605) | 評(píng)論 (0)編輯 收藏

          全選輸出checkbox的值

          $("input[name='a']").each(function () {
                      Aval 
          = $(this).val();
                      alert(Aval);
                  });

          解釋:取當(dāng)前頁(yè)面所有name='a'的input元素,循環(huán)每一個(gè)取到的元素,將其value的值賦

          給Aval,并輸出。


          posted @ 2019-05-11 14:48 半導(dǎo)體 閱讀(100) | 評(píng)論 (0)編輯 收藏

          mysql8.0使用sqlyog無(wú)法連接時(shí)

           ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';

           ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';

          如果mysql只能本地連接,不能遠(yuǎn)程 連接
          第一步:
           update user set host='%' where user='root';
          第二步:重啟服務(wù)

          posted @ 2019-05-06 10:14 半導(dǎo)體 閱讀(259) | 評(píng)論 (0)編輯 收藏

          jquery常用語(yǔ)法

          $(":text[name='username']").val()

          $("#logOn").click(function () {
          });
          1、jquery引入基本語(yǔ)法:
           $(function(){});

          2、觸發(fā)所有button元素的click事件
              $(
          ":button").click( ); // 調(diào)用不帶任何參數(shù)的click()函數(shù),會(huì)觸發(fā)每個(gè)匹配元素的click事件.
           3、// 點(diǎn)擊鏈接時(shí),阻止鏈接跳轉(zhuǎn)
              $(
          "a").click( function(){
                 
          return false;
              } );

          posted @ 2019-05-04 21:57 半導(dǎo)體 閱讀(106) | 評(píng)論 (0)編輯 收藏

          springboot+ssm+mysql 錯(cuò)誤記錄

          HikariPool-1 - Driver does not support get/set network timeout for connections. (com.mysql.jdbc.JDBC4Connection.getNetworkTimeout()I)
          解決辦法:在application.properties數(shù)據(jù)庫(kù)連接中增加:&serverTimezone=UTC
          Registered driver with driverClassName=com.mysql.jdbc.Driver was not found, trying direct instantiation.
          解決辦法:打開(kāi)mysql,輸入set global time_zone='+8:00';
          還有給我自己提個(gè)醒,報(bào)錯(cuò)信息千萬(wàn)別只看一句,如果第一句報(bào)錯(cuò)沒(méi)給你答案,后面的報(bào)錯(cuò)信息繼續(xù)看。

          posted @ 2019-04-29 23:05 半導(dǎo)體 閱讀(517) | 評(píng)論 (0)編輯 收藏

          字符串型轉(zhuǎn)換為JSON并獲取值

          @RequestMapping(value = "updateInvestorApplyAccountNo", method = RequestMethod.POST)
          @ResponseBody
          public void updateInvestorApplyAccountNo(HttpServletRequest request,
          HttpServletResponse response,
          @RequestBody String requestBody) {
          int num = 0;
          String result = "";
          //下面是把拿到的json字符串轉(zhuǎn)成 json對(duì)象
          JSONObject jsStr = JSONObject.parseObject(requestBody); //將字符串{“id”:1}
          //int jsID = Integer.parseInt(jsStr.getString("id"));//獲取id的值


          /** 
          * json對(duì)象轉(zhuǎn)換成java對(duì)象 
          */ 
          InvestorApplyModel stud = (InvestorApplyModel) JSONObject.toJavaObject(jsStr,InvestorApplyModel.class);

          }

          posted @ 2018-08-25 15:38 半導(dǎo)體 閱讀(173) | 評(píng)論 (0)編輯 收藏

          主站蜘蛛池模板: 两当县| 林口县| 师宗县| 舟曲县| 交口县| 田东县| 北辰区| 育儿| 崇礼县| 鹤庆县| 锡林郭勒盟| 方城县| 白银市| 龙泉市| 文昌市| 富源县| 台江县| 玉门市| 曲麻莱县| 土默特左旗| 阿拉善右旗| 天门市| 开远市| 南康市| 五大连池市| 普兰店市| 兰西县| 金川县| 商水县| 成武县| 大庆市| 大厂| 荣昌县| 琼中| 江川县| 博乐市| 平阳县| 武宁县| 华亭县| 中宁县| 柘城县|